开发者

fork: Resource temporarily unavailable when calling rvm from a shell script, but rvm works fine by itself

I want to switch between different projects, and one part of that is changing rubies and gemsets via rvm. RVM works great for me by itself, but when I put a call to it into a shell script, I get:

fork: Resource temporarily unavailable

Here's the output from rvm info. Let me know if there's any other info I can give that would be useful.

$ rvm info

ruby-1.9.2-p136@pax-arachnae:

  system:
    uname:       "Darwin savoy.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.0.9 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.开发者_Python百科com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p136"
    date:         "2010-12-25"
    platform:     "x86_64-darwin10.6.0"
    patchlevel:   "2010-12-25 revision 30365"
    full_version: "ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]"

  homes:
    gem:          "/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@pax-arachnae"
    ruby:         "/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136"

  binaries:
    ruby:         "/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136/bin/ruby"
    irb:          "/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136/bin/irb"
    gem:          "/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136/bin/gem"
    rake:         "/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@pax-arachnae/bin/rake"

  environment:
    PATH:         "/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@pax-arachnae/bin:/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@global/bin:/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136/bin:/Users/rfzabick/.rvm/bin:/usr/local/bin:/Applications/Emacs.app/Contents/MacOS:/Applications/MacVim.app/Contents/MacOS:/usr/local/mysql/bin:/Developer/usr/bin:/Users/rfzabick/.ec2/ec2-api-tools-1.3-62308/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/Applications/Google Chrome.app/Contents/MacOS"
    GEM_HOME:     "/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@pax-arachnae"
    GEM_PATH:     "/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@pax-arachnae:/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@global"
    BUNDLE_PATH:  "/Users/rfzabick/.rvm/gems/ruby-1.9.2-p136@pax-arachnae"
    MY_RUBY_HOME: "/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136"
    IRBRC:        "/Users/rfzabick/.rvm/rubies/ruby-1.9.2-p136/.irbrc"
    RUBYOPT:      ""
    gemset:       "pax-arachnae"


I use RVM in shell scripts and it works fine. One thing that might explain why you're unable to, is your version is old. The current version is 1.2.8, and you're on 1.0.9.

RVM updates often, so it's a good idea to update it every couple weeks at least. In the current RVM we'd use rvm get head to update, but I'm not sure it that was the same in 1.0.9. If not try rvm help update.


fork: Resource temporarily unavailable

The error is caused by the current shell resource limits set by ulimit (check by ulimit -a). So you can either try in another shell, or increase the resources by using ulimit command which controls over the resources available to the shell and processes it creates on operating system.

To increase the limits, try running:

ulimit -Sn unlimited && ulimit -Sl unlimited

to raise the soft limits to hard one, or:

ulimit -l unlimited
ulimit -n 10240 

to set the maximum size a process to unlimited and the maximum number of open file to 10240.

See: help ulimit for more information.

To increase process limit, use this command:

sudo launchctl limit maxproc 1024 2048

See also: How to persist ulimit settings in OSX?


Just had an issue and solved it on red hat 5 getting error: fork: Resource temporarily unavailable

Research we did found this: 1. cron run scripts do not fully logon as the user. So if ulimit commands are issued in /etc/profile they will not get run when cron scripts run.

  1. In dealing with user oracle on a machine with many databases, we found the ulimit -u to cause the issue. We had 800 oracle processes running (shows with ps -ef|grep oracle|wc -l), but a bash shell would work ok with ulimit -u 2020 but would fail with ulimit -u 2010.

Turns out process limits must be a misnomer. Must include threads also. This command shows a number closer to our experience of what ulimit -u needed: ps -eLf|grep oracle|egrep -v root|wc -l

So the bottom line is, make sure your ulimit -u is set high enough when dealing with workloads such as oracle.


I also had the same error, but for me my rvm had been messed up and was using ruby 1.8.7 instead of 1.9.3. I did rvm requirements and it warned me about it. changed back to 1.9.3 and it all started working again.


I had the same problem with system ruby 1.8.7 on OSX 10.7. I'm using RVM so simply switching to different ruby 1.9.2-p290 solved the problem. (I don't use 1.8.7 in any project anyway).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜