我的开发环境已经消失,我在尝试修复它时遇到了一系列错误

所以我和我的一个朋友搞乱了gem,我不小心删掉了一个。 我不确定发生了什么事,所以我只是把它擦掉了。


然后我去为我的旧应用程序运行’rails server’,我一直在努力,没有任何事情发生在2分钟,然后最终它吐出一个错误。

/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 

那么我做了下面提出的所有建议,我遇到了各种各样的错误。 如果我要为每个错误创建一个单独的问题,我认为我会弄乱堆栈溢出,所以我想在这里给出一些解决这个问题的顺序。

现在我正在试图回溯并弄清楚发生了什么……每当我在答案中运行这些不同的命令时我就会改变一些事情而我不知道发生了什么。


当我尝试安装ruby版本时,我收到此错误:

 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 

我在某处读到安装xCode会解决这个问题,所以我安装了它。 虽然我得到了同样的错误。


当我尝试运行该错误的第一个建议时,我得到了这个:

 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. 

当我运行第二个建议时它会返回

 gcc-4.2 not found 

通常当我运行’ruby -v’或’rails -v’时,它会返回版本名称。 现在它只返回与运行’rails s’时完全相同的错误

如果我尝试将gemsets从默认切换到全局,它说

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

但是如果我尝试安装它,我会得到相同的gcc错误。


当我尝试安装rails时,我收到有关安装libyaml的错误,我安装了10次:

 ➜ 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 `': 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 

我的问题是……发生了什么,我怎样才能回到我可以运行rails的地方,然后安静地工作我的应用程序!? 大声笑

你得到的错误:

 /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 

显示没有使用rvm ruby​​,请确保在使用前先使用ruby:

 rvm use ruby 

如果你想使用为当前目录项目使用定义的ruby:

 rvm use --install --create . 

--install--create标志将处理丢失的ruby和gemset。

让我们澄清一下:无法从gemset更改Gemfile

Gemset的目标是为您的应用程序提供独立的gem安装。

要使用RVM Gemset,您应该执行以下操作:

  1. validation您是否拥有最新的rvm (在控制台中运行):

    rvm稳定

  2. 检查你有哪个ruby版本: rvm list和gemsets: rvm gemset list

  3. 假设,新的gemset名称是myapp 。 您应该创建如下:

    rvm gemset创建myapp

  4. 在应用程序根文件夹中添加以下文件: .ruby-gemset.ruby-version

    .ruby-version包含要使用的ruby版本.ruby-gemset包含gemset名称

  5. 关闭控制台并打开一个新控制台。 转到项目文件夹,应该准备好一个新的gemset。 重复步骤2以validation您的gemset配置正确。

  6. 安装捆绑包:

    gem install bundler bundle install

示例 :create .ruby- * config files:

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

注意:

要将当前gemset设置为默认值,请执行以下操作: rvm use ruby-1.9.3-p429@myapp --default