我正在尝试在运行OS X 10.6.3,Ruby 1.8.7和Rails 2.3.5的全新MacBook Pro上安装Rails 3,我想知道我是否已经自己洗了.到目前为止,我已经运行了这些命令:
$ gem update --system
$ gem install arel tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install rails --pre
Run Code Online (Sandbox Code Playgroud)
但是,当我运行最后一个命令时,我收到此错误:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.
Run Code Online (Sandbox Code Playgroud)
我认为它希望我运行命令,sudo以便它可以写入/usr/bin/rails.但如果我这样做,我不会覆盖我的Rails 2.3.5可执行文件吗?我不想那样做.相反,我想保留两个版本的Rails.我怎么做?
我正在执行以下脚本:
gem install rdoc --no-document
gem install bundle
bundle
Run Code Online (Sandbox Code Playgroud)
输出:
+ gem install rdoc --no-document
Successfully installed rdoc-6.1.1
1 gem installed
+ gem install bundle
Successfully installed bundle-0.0.1
Parsing documentation for bundle-0.0.1
Done installing documentation for bundle after 2 seconds
1 gem installed
1 gem installed
+ bundle install
/usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
from /usr/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
from /srv/myuser/.gem/ruby/2.5.0/bin/bundle:23:in `<main>'
Run Code Online (Sandbox Code Playgroud)
我添加/srv/myuser/.gem/ruby/2.5.0/bin到我的路径,所以我能够安装宝石.
该gem env节目
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.7 …Run Code Online (Sandbox Code Playgroud) 我是rbenv的新手(长时间使用RVM).今天我清理卸载我的RVM并安装rbenv.我设法安装Ruby 2.5.1没有任何问题.
但是当我bundle install今天尝试运行一个项目时,我收到以下错误:
'find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
看来我的捆绑安装已经破坏了一些东西,但我不确定是什么问题.运行gem install bundler有sudo没有解决的问题.
这是完整的痕迹:
$ echo $SHELL
/bin/zsh
$ cat ~/.gemrc
gem: --no-document
install: --no-document
update: --no-document
$ rbenv versions
system
* 2.5.1 (set by /Users/zulh/.rbenv/version)
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
$ which ruby
/Users/zulh/.rbenv/shims/ruby
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin16]
- INSTALLATION DIRECTORY: …Run Code Online (Sandbox Code Playgroud) irb使用Homebrew安装Ruby后如何工作?
当我尝试运行时irb,出现错误:
$ irb
Traceback (most recent call last):
2: from /usr/local/opt/ruby/bin/irb:23:in `<main>'
1: from /usr/local/lib/ruby/site_ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/site_ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem irb (>= 0.a) with executable irb (Gem::GemNotFoundException)
Run Code Online (Sandbox Code Playgroud)
我试过了:
$ brew link ruby
Warning: Refusing to link macOS-provided software: ruby
If you need to have ruby first in your PATH run:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
For compilers to find ruby you may need to set:
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
Run Code Online (Sandbox Code Playgroud)
我的/etc/paths文件顶部下面有几行:
/usr/local/bin
/usr/local/opt/ruby/bin
/usr/local/lib/ruby/gems/2.6.0/bin …Run Code Online (Sandbox Code Playgroud)