My development environment was wiped out and I'

2019-08-28 12:46发布

问题:

So I was messing with gemsets with a friend of mine and I accidentally deleted a one. I wasn't sure what happened, so I just kinda brushed it off.


Then I went to run 'rails server' for my old app that I've been working on and nothing happens for like 2 minutes and then finally it spits out an error.

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

So then I did everything suggested below and I've gotten all kinds of errors. If I were to create a seperate question for every error I think I'd be making a mess of stackoverflow, so I want to give some kind of order to solving this here.

Right now I'm trying to backtrack and figure out what happened... Every time I run these different commands in an answer I'm changing things while I have no idea what's going on.


When I try to install a version of ruby I get this error:

apple-gcc42 is not available in PATH, try:

brew unlink apple-gcc42 && brew link apple-gcc42

and make sure that apple-gcc42 is available in your PATH:

which gcc-4.2

I read somewhere that installing xCode would solve this, so I installed it. Although I get the same error.


When I try to run the first suggestions from that error I get this:

Unlinking /usr/local/Cellar/apple-gcc42/4.2.1-5666.3... 0 links removed
Linking /usr/local/Cellar/apple-gcc42/4.2.1-5666.3... Warning: Could not link apple-gcc42.     
Unlinking...

Error: Could not symlink file: /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/include/gcc
/usr/local/include is not writable. You should change its permissions.

When I run the second suggestions it returns

gcc-4.2 not found

Usually when I run 'ruby -v' or 'rails -v' it returns the version name. Now it just returns the exact same error as when I run 'rails s'

If I try to switch gemsets from default to global it says

To install do: 'rvm install ruby-1.9.3-p125'

But then if I try to install it I get the same gcc error.


When I try to install rails I get this error about installing libyaml, which I've installed like 10 times:

➜  app3 git:(add_food_servings) ✗ gem install rails
 /Users/Nick/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/yaml.rb:4:in `<top (required)>':
 It seems your ruby installation is missing psych (for YAML output).
 To eliminate this warning, please install libyaml and reinstall your ruby.
 /Users/Nick/.rvm/rubies/ruby-2.0.0-  
  p247/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require':  
 dlopen(/Users/Nick/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/psych.bundle, 9): Library not loaded: /usr/local/opt/libyaml/lib/libyaml-0.2.dylib (LoadError)
  Referenced from: /Users/Nick/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin11.4.2/psych.bundle

My question is... what's going on and how can I get back to where I was when I could run rails s and just work on my app in peace!? lol

回答1:

The error you got:

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

shows that rvm ruby was not used, make sure you use ruby first before working:

rvm use ruby

if you want to use ruby which is defined for current directory project use:

rvm use --install --create .

the --install and --create flags will take care of missing ruby and gemset.



回答2:

Let's clarify: The Gemfile cannot be changed from gemset

Gemset goal to provide you independent installation of gems for your application.

To work with RVM Gemset you should do the following:

  1. Verify you have the latest rvm (run in your console):

    rvm get stable

  2. Check which ruby version do you have: rvm list and gemsets: rvm gemset list

  3. Let assume, the new gemset name is myapp. You should create it as following:

    rvm gemset create myapp

  4. Add the following files inside your application root folder: .ruby-gemset and .ruby-version

    .ruby-version contains ruby version you want to use and .ruby-gemset contains gemset name

  5. Close your console and open a new one. Go to you project folder and a new gemset should be ready. Repeat step 2 to verify your gemset configured properly.

  6. Install bundler:

    gem install bundler bundle install

Example: create .ruby-* config files:

echo "ruby-1.9.3-p429" > .ruby-version

echo "myapp" > .ruby-gemset

Note:

To make current gemset as default, do the following: rvm use ruby-1.9.3-p429@myapp --default