Ruby 초보자가 옛 Rails와 Ruby를 구축할 때의 해피.
컨디션
개인적인 이유로 낡은 루비와 라일스 환경을 구축해야 하고, 루비의 초보자인 저에게 적합한 일과 해결 방법을 소개하고 싶습니다.
누군가를 도울 수 있었으면 좋겠어요.
자기 환경
목표
Ruby
> brew install rbenv
eval "$(rbenv init -)"
> rbenv install 2.2.3
> rbenv global 2.2.3
> ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin18]
Ruby 설치 자체에는 문제가 없습니다.Rails(nokogiri 오류)
여기서 지옥으로 들어갔어.
목표 rails4.2.5.1의 설치 명령을 눌렀을 때 nokogiri 오류가 발생했습니다!
컴퓨터 "2.3 이상의 루비를 설치하세요!"
"그건 안 돼!"
> gem install rails --version="4.2.5.1"
...
...
...(詳細略)
Fetching: nokogiri-1.9.1.gem (100%)
ERROR: Error installing nokogiri:
nokogiri requires Ruby version >= 2.3.0.
다방면의 조사를 통해 nokogiri가 의존하는 C 언어 라이브러리,libxml 2libxslt libiconv가 필요할 것 같습니다brew로 설치해 주세요.
> brew install libxml2 libxslt libiconv
설치가 끝났지만 brew list를 보면 libiconv만 발견됩니다. 링크가 설정되지 않았기 때문입니다.다음 brew link 설정
> brew link --force libxml2 libxslt libiconv
그리고 링크에서 설정하면 또 오류가 발생합니다...
Warning: Refusing to link macOS-provided software: libxml2
If you need to have libxml2 first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.zshrc
For compilers to find libxml2 you may need to set:
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
For pkg-config to find libxml2 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
Warning: Refusing to link macOS-provided software: libxslt
If you need to have libxslt first in your PATH run:
echo 'export PATH="/usr/local/opt/libxslt/bin:$PATH"' >> ~/.zshrc
For compilers to find libxslt you may need to set:
export LDFLAGS="-L/usr/local/opt/libxslt/lib"
export CPPFLAGS="-I/usr/local/opt/libxslt/include"
For pkg-config to find libxslt you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/libxslt/lib/pkgconfig"
Warning: Refusing to link macOS-provided software: libiconv
If you need to have libiconv first in your PATH run:
echo 'export PATH="/usr/local/opt/libiconv/bin:$PATH"' >> ~/.zshrc
For compilers to find libiconv you may need to set:
export LDFLAGS="-L/usr/local/opt/libiconv/lib"
export CPPFLAGS="-I/usr/local/opt/libiconv/include"
자신에게 추가를 요구받다.zshrc에 다음과 같이 추가 export PATH="/usr/local/opt/libxml2/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
export PATH="/usr/local/opt/libxslt/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/libxslt/lib"
export CPPFLAGS="-I/usr/local/opt/libxslt/include"
export PATH="/usr/local/opt/libiconv/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/libiconv/lib"
export CPPFLAGS="-I/usr/local/opt/libiconv/include"
gem install rails--version="4.2.5.1"다시 한 번 쳐주세요.railst와 nokogiri를 무사히 설치했습니다!!!
> rails -v
Rails 4.2.5.1
> nokogiri -v # Nokogiri (1.9.1)
---
warnings: []
nokogiri: 1.9.1
ruby:
version: 2.2.3
platform: x86_64-darwin18
description: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin18]
engine: ruby
libxml:
binding: extension
source: system
compiled: 2.9.9
loaded: 2.9.9
Rails 엔지니어링 제작(sqlite3 오류)
적당히 프로젝트를 하다
> rails new rails-sample
여기 bundle install, nokogiri가 잘 안 풀린다는 기사가 많아요.역시 자신의 상황은 C쿠 때문이죠.
libxml2libxslt libiconv,brew에 설치하고zshrc에 추가합니다.nokogiri가 잘 설치할 수 있다면 문제없을 것입니다!
응용 프로그램 시작
> rails s
=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2019-05-25 15:18:02] INFO WEBrick 1.3.1
[2019-05-25 15:18:02] INFO ruby 2.2.3 (2015-08-18) [x86_64-darwin18]
[2019-05-25 15:18:02] INFO WEBrick::HTTPServer#start: pid=15720 port=3000
성공적으로 시작했습니다!생각지도 못하다Gem::LoadError,
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
어쨌든 일단 Gemfile로 찾아볼게요.# Use sqlite3 as the database for Active Record
gem 'sqlite3'
느릿느릿있잖아.gem list로 보면...
> gem list
...
...
sqlite3 (1.4.1) <--ちゃんとインストールしているんじゃん
...
...
이유:# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.6'
bundle update sqlite3 명령 패키지로 업데이트
Fetching sqlite3 1.3.13 (was 1.4.1)
Installing sqlite3 1.3.13 (was 1.4.1) with native extensions
Using turbolinks-source 5.2.0
Using turbolinks 5.2.0
Using uglifier 4.1.20
Using web-console 2.3.0
Bundle complete! 12 Gemfile dependencies, 59 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
애플리케이션 시작 후> rails s
=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2019-05-25 15:32:01] INFO WEBrick 1.3.1
[2019-05-25 15:32:01] INFO ruby 2.2.3 (2015-08-18) [x86_64-darwin18]
[2019-05-25 15:32:01] INFO WEBrick::HTTPServer#start: pid=16928 port=3000
드디어!!!!!사용 중 오류
gemfile에gem "mysql2"를 직접 쓰면 bundle 설치 오류
잘못된 내용
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
해결책1. brew install opensll
2.zshrc에 추기
3.4.2.5일 때 mysql은 0.4입니다.x계의gem 사용하기
gem "mysql2", "~> 0.4.0"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
gemlock를 한 번 삭제하면 순조롭게 진행될 수 있습니다결론
최신 사용이 최고예요!
Reference
이 문제에 관하여(Ruby 초보자가 옛 Rails와 Ruby를 구축할 때의 해피.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/jakushin/items/93cdecab160f5bbec86c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)