Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

ruby

rvm

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 ([email protected]) [http://rvm.beginrescueend.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"
like image 211
Roman Zabicki Avatar asked Mar 05 '11 02:03

Roman Zabicki


2 Answers

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.

like image 161
the Tin Man Avatar answered Sep 26 '22 19:09

the Tin Man


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?

like image 20
kenorb Avatar answered Sep 24 '22 19:09

kenorb