CodeboxIDE / codebox

Open source cloud & desktop IDE
https://www.codebox.io
Apache License 2.0
4.12k stars 588 forks source link

how to run a ruby project with gem dependences? example appreciated #335

Open terryg opened 10 years ago

terryg commented 10 years ago

\ Here's my experience with Ruby on Rails **

I'm getting the following when I select Project -> Run:

14:46:13 web.1  | 'bundle exec rackup config.ru -p $PORT' started with pid 274                                                          
14:46:13 web.1  | ERROR: RVM Ruby not used, run `rvm use ruby` first.                                                                   
SIGINT received                                                                                                                         
sending SIGTERM to all processes                                                                                                        
####                                                                                                                                    
# Press ENTER to close this shell ...                                                                                                   
####                                                                                                                                    

I've executed 'rvm use ruby' in the Terminal, but I still get the same error.

I've also tried 'bundle exec rackup config.ru -p 5000' in the Terminal, then I get gem errors. 'bundle install' helped with some gems, but compiling the postgres gem failed.

I ran 'sudo apt-get install -y postgresql', that worked.

'bundle install' still failing:

aN;NaNfcodebox@7c726cec32e4:~/workspace$ bundle install                                                                                 
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /usr/local/rvm/gems/ruby-2.1.0/extensions/x86_64-linux/2.1.0/json-1.7.7 (Errno::EACCES) 

'sudo bundle install' doesn't work:

codebox@7c726cec32e4:~/workspace$ sudo bundle install                                                                                   
sudo: bundle: command not found                                                                                                         
codebox@7c726cec32e4:~/workspace$      

I'd be happy to RTFM, but there doesn't seem to be any content under the "Autorun" topic: http://help.codebox.io/ide/autorun.html

\ And here is a try at Sinatra ***

codebox@70ae71936546:~/workspace$ mkdir -p ../rvm/gems/ruby-2.1.0/bin                                                                                                                                                           
codebox@70ae71936546:~/workspace$ export GEM_HOME=/home/codebox/rvm/gems/ruby-2.1.0/                                                    
codebox@70ae71936546:~/workspace$ gem install sinatra                                                                                   
Fetching: sinatra-1.4.5.gem (100%)                                                                                                      
Successfully installed sinatra-1.4.5                                                                                                    
Parsing documentation for sinatra-1.4.5                                                                                                 
Installing ri documentation for sinatra-1.4.5                                                                                           
Done installing documentation for sinatra after 71 seconds                                                                              
1 gem installed                                                                                                                                                                                                                               
codebox@70ae71936546:~/workspace$ ruby app.rb                                                                                           
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /usr/local/rvm/gems/ruby-2.1.0/extensions/x86_64-linux/2.1.0/http_parser.rb-0.6.0 (Errno::EACCES)           
AaronO commented 10 years ago

@terryg Sorry about that. There's a fault in the default permissions set for rvm, we were planning on pushing new stacks in the coming days, so I'll bundle a fix for this in the ruby stack.

In the meanwhile, run this command once and you should be good :

sudo chmod o+rw -R /usr/local/rvm/

This fixes the permission issues with rvm.

After than I can run sinatra with no issues, using this sample code :

require 'sinatra'

get '/' do
  'Hello world!'
end

set :bind, '0.0.0.0'

Make sure that your server binds to 0.0.0.0 so it can be accessed externally.

@terryg Let me know if this helps.

Thanks for reporting this and sorry for the inconvenience.

terryg commented 10 years ago

Thanks @AaronO! Did you run this via Project -> Run or directly in the Terminal? Can you share the Procfile? I'm still getting the "rvm use ruby" first error.

jmccaffrey commented 10 years ago

@AaronO thanks for posting the solution, I got my gems installed and my rails app working