RVM ruby installation issue

2019-07-19 17:25发布

问题:

I've already got ruby and rails installed for some time and worked on some projects. Lately I've installed the Xcode 5 developer preview in order to get my apps ready for iOS 7. I'm just mentioning this in case the new Xcode messed it up.

I first noticed the error when trying to

rake asets:precompile

in the rails project directory. It gives the following error:

/Users/User/.rvm/bin/ruby: line 6: /Users/User/.rvm/bin/ruby: Argument list too long /Users/User/.rvm/bin/ruby: line 6: /Users/User/.rvm/bin/ruby: Undefined error: 0

When I try:

ruby -v

The terminal window gives no response at first, the terminal title flickers between "bash" and "env", but then shows the following error:

/Users/User/.rvm/bin/ruby: line 6: /Users/User/.rvm/bin/ruby: Argument list too long
/Users/User/.rvm/bin/ruby: line 6: /Users/User/.rvm/bin/ruby: Undefined error: 0

And when I try

rvm get stable

I get:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   184  100   184    0     0     67      0  0:00:02  0:00:02 --:--:--   163
100 13774  100 13774    0     0   3469      0  0:00:03  0:00:03 --:--:-- 75267
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   124  100   124    0     0    227      0 --:--:-- --:--:-- --:--:--   306
100 1080k  100 1080k    0     0   286k      0  0:00:03  0:00:03 --:--:--  491k

Upgrading the RVM installation in /Users/User/.rvm/
chmod: Unable to change file mode on /Users/User/.rvm/scripts/aliases: Operation not permitted
chmod: Unable to change file mode on /Users/User/.rvm/scripts/fix-permissions: Operation not permitted
chmod: Unable to change file mode on /Users/User/.rvm/scripts/irbrc: Operation not permitted
chmod: Unable to change file mode on /Users/User/.rvm/scripts/irbrc.rb: Operation not permitted
    Failed to set permissions of: /Users/User/.rvm/scripts/aliases /Users/User/.rvm/scripts/fix-permissions /Users/User/.rvm/scripts/irbrc /Users/User/.rvm/scripts/irbrc.rb, prefix the command with 'rvmsudo' to fix it, if the situation persist report a bug.
    RVM PATH line found in /Users/User/.bashrc /Users/User/.zshrc.
    RVM sourcing line found in /Users/User/.bash_profile /Users/User/.zprofile.
Upgrade of RVM in /Users/User/.rvm/ is complete.

# User,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne

# In case of problems:
#      run and read: rvm notes
#         read docs: http://rvm.io/
#        talk to us: http://webchat.freenode.net/?channels=rvm (http://freenode.net/faq.shtml#plusr)
#   read cheatsheet: http://cheat.errtheblog.com/s/rvm
#  watch screencast: http://screencasts.org/episodes/how-to-use-rvm
# open a bug report: https://github.com/wayneeseguin/rvm/issues

Upgrade Notes:

  * No new notes to display.

RVM reloaded!

And finally, when I enter:

rvm install ruby-2.0.0-p247

I get:

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p247.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Installing Ruby from source to: /Users/User/.rvm/rubies/ruby-2.0.0-p247, this may take a while depending on your cpu(s)...
ruby-2.0.0-p247 - #downloading ruby-2.0.0-p247, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.3M  100 10.3M    0     0   129k      0  0:01:21  0:01:21 --:--:--  264k
ruby-2.0.0-p247 - #extracting ruby-2.0.0-p247 to /Users/User/.rvm/src/ruby-2.0.0-p247
ruby-2.0.0-p247 - #extracted to /Users/User/.rvm/src/ruby-2.0.0-p247
ruby-2.0.0-p247 - #configuring....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ruby-2.0.0-p247 - #compiling........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ruby-2.0.0-p247 - #installing..................................................................................................................................
Retrieving rubygems-2.0.6
Extracting rubygems-2.0.6 ...
Removing old Rubygems files...
Installing rubygems-2.0.6 for ruby-2.0.0-p247...................................
Error running 'env GEM_PATH=/Users/User/.rvm/gems/ruby-2.0.0-p247:/Users/User/.rvm/gems/ruby-2.0.0-p247@global:/Users/User/.rvm/gems/ruby-2.0.0-p247:/Users/User/.rvm/gems/ruby-2.0.0-p247@global GEM_HOME=/Users/User/.rvm/gems/ruby-2.0.0-p247 /Users/User/.rvm/rubies/ruby-2.0.0-p247/bin/ruby -d /Users/User/.rvm/src/rubygems-2.0.6/setup.rb',
please read /Users/User/.rvm/log/ruby-2.0.0-p247/1374852277_rubygems.install.log
Installation of rubygems did not complete successfully.
Saving wrappers to '/Users/User/.rvm/wrappers/ruby-2.0.0-p247'........

ruby-2.0.0-p247 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-2.0.0-p247 - #importing default gemsets, this may take time...............................
Install of ruby-2.0.0-p247 - #complete 

But its still the same as before.

As far as I know I haven't changed anything to the system, I've only installed the new Xcode. Does someone know whats wrong here? Unfortunately these rvm / ruby / terminal commands, or more precisely, how this ruby install path-permission-rights thing is still very new to me. Thank you very much for your time!

回答1:

make sure your rvm is up to date:

rvm get stable

then you need to run:

rvm use ruby

this will ensure your environment is set up properly, it does display warnings if something is wrong, you need to read the warnings always - and follow the instructions

to make the use ruby persist for next shell sessions use:

rvm use --default ruby

it will create the default alias which is loaded when rvm is started



回答2:

Looks like the error is occurring in your gem path. Are you sure the @global gemset exists? Running the following should clear up the issue.

rvm gemset create global