WebFaction
Community site: login faq

I'm a Ruby newbie, evaluating Rails for a new project. I'm working through the Rails "Getting Started" tutorial (http://guides.rubyonrails.org/getting_started.html) in the WF environment, using a Rails installation set up through the Control Panel.

Inside the installation folder, webapps/rails_eval, I've set up an app named blog, whose base folder is therefore at webapps/rails_eval/blog. Now I'm at step 4.2 of the Rails tutorial, which tells me to run the command $ bin/rails generate controller welcome index.

Here's where I hit the problem:

[sunward@web324 rails_eval]$ cd blog
[sunward@web324 blog]$ bin/rails generate controller welcome index
/usr/local/lib/ruby21/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
        from /usr/local/lib/ruby21/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/sunward/webapps/rails_eval/blog/config/boot.rb:3:in `<top (required)>'
        from bin/rails:7:in `require_relative'
        from bin/rails:7:in `<main>'
[sunward@web324 blog]$ cd app/controllers
[sunward@web324 controllers]$ dir
application_controller.rb  concerns

Two problems (or two symptoms of one problem) here: (1) The error message. (2) The last dir command shows that the controller that was supposed to be generated, welcome_controller.rb, was not generated.

Before doing this on WF, I successfully did this step on my local Windows machine.

~ TIA, Ken

asked 22 May '15, 18:44

kenatsun
1929
accept rate: 20%

We haven't been able to determine from the cause of the problem from the information provided. Can try including your environment information in your question (view this with "env")? That might offer additional clues.

(23 May '15, 09:29) ryans ♦♦

Is this what you're looking for?:

[sunward@web324 controllers]$ env
HOSTNAME=web324.webfaction.com
MAILTO=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=107.5.46.133 58269 22
OLDPWD=/home/sunward/webapps/rails_eval/blog
SSH_TTY=/dev/pts/16
JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
USER=sunward
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL=/var/spool/mail/sunward
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/sunward/bin
PWD=/home/sunward/webapps/rails_eval/blog/app/controllers
LANG=en_US.UTF-8
CATALINA_OPTS=-server -Xmx300m
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/sunward
LOGNAME=sunward
CVS_RSH=ssh
SSH_CONNECTION=107.5.46.133 58269 75.126.149.5 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
MAILFROM=root@web324.webfaction.com
G_BROKEN_FILENAMES=1
_=/bin/env
(23 May '15, 17:09) kenatsun

Please try it like this, exactly as shown below:

cd ~/webapps/rails_eval
export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib
export PATH=$PWD/bin:$PATH
export TMPDIR=$PWD/tmp
export DISABLE_SPRING=1
cd blog
rails generate controller welcome index
permanent link

answered 25 May '15, 17:12

seanf
12.2k41836
accept rate: 37%

That did it! Apparently DISABLE_SPRING=1 was the key. See listing below.

~ Thannks, Ken

[sunward@web324 blog]$ cd ~/webapps/rails_eval
[sunward@web324 rails_eval]$ export GEM_HOME=$PWD/gems
[sunward@web324 rails_eval]$ export RUBYLIB=$PWD/lib
[sunward@web324 rails_eval]$ export PATH=$PWD/bin:$PATH
[sunward@web324 rails_eval]$ export TMPDIR=$PWD/tmp
[sunward@web324 rails_eval]$ export DISABLE_SPRING=1
[sunward@web324 rails_eval]$ cd blog
[sunward@web324 blog]$ rails generate controller welcome index
      create  app/controllers/welcome_controller.rb
       route  get 'welcome/index'
      invoke  erb
      create    app/views/welcome
      create    app/views/welcome/index.html.erb
      invoke  test_unit
      create    test/controllers/welcome_controller_test.rb
      invoke  helper
      create    app/helpers/welcome_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/welcome.coffee
      invoke    scss
      create      app/assets/stylesheets/welcome.scss
[sunward@web324 blog]$ cd app/controllers
[sunward@web324 controllers]$ ls
application_controller.rb  concerns  welcome_controller.rb
(25 May '15, 17:32) kenatsun

You've gotten me past this hurdle - thanks again, and may I tack on one more question?

The key to this solution (and some other problems I have encountered) has been to run these commands:

export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib
export PATH=$PWD/bin:$PATH
export TMPDIR=$PWD/tmp
export DISABLE_SPRING=1

This advice (except for the last command) is repeated several times in the WF RoR doc (https://docs.webfaction.com/software/rails.html?highlight=rails#ruby-on-rails). Apparently this has to be done each time one logs in to a new console session.

My question is: Isn't there some way to "automate" running these commands, so they don't have to be keyed in every session? I tried semi-automating them by putting them into a bash shell script, but that doesn't seem to actually effectively execute them. So the only streamlining I have come up with so far is to put the commands in a text file, from which I copy-and-paste them into the console. Pretty clunky.

Is there a better way?

~ Tx Ken

(28 May '15, 00:04) kenatsun

The most common way is to add them to your "~/.bash_profile" file, which is a shell script that runs automatically every time you log in. However, that really only works effectively if you're only writing/managing one application at a time.

What I would do is to list the commands in a file named something like "env.bash":

export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib
export PATH=$PWD/bin:$PATH
export TMPDIR=$PWD/tmp
export DISABLE_SPRING=1

and then each time run "source env.bash" (or, equivalently, ". env.bash"). Keeping one of these files in each application allows you to set an arbitrary environment in a single line, which is just as efficient as a python virtualenv's "source bin/activate" convention.

(28 May '15, 00:31) ryans ♦♦

Thanks again, Sean ~ That does it! ~ Ken

(01 Jun '15, 20:05) kenatsun

It looks like your PATH, GEM_HOME, and RUBYLIB environment variables aren't set, which can confuse the tools and software you're using. Can you try setting them as described in our Rails Documentation:

cd $HOME/webapps/rails_eval
export PATH=$PWD/bin:$PATH
export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib

And then, try running "rails generate controller welcome index" (the correct "rails" should be chosen automatically as a result of your $PATH).

permanent link

answered 24 May '15, 00:47

ryans ♦♦
5.0k93160
accept rate: 43%

I think it didn't work. Here's the "printout":

[sunward@web324 blog]$ cd $HOME/webapps/rails_eval
[sunward@web324 rails_eval]$ export PATH=$PWD/bin:$PATH
[sunward@web324 rails_eval]$ export GEM_HOME=$PWD/gems
[sunward@web324 rails_eval]$ export RUBYLIB=$PWD/lib
[sunward@web324 rails_eval]$ rails generate controller welcome index
Usage:
  rails new APP_PATH [options]

Options:
...

If I run "env" again, it still looks like this:

[sunward@web324 rails_eval]$ env
HOSTNAME=web324.webfaction.com
GEM_HOME=/home/sunward/webapps/rails_eval/gems
MAILTO=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=107.5.46.133 53789 22
OLDPWD=/home/sunward/webapps/rails_eval/blog
SSH_TTY=/dev/pts/16
JRE_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
USER=sunward
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL=/var/spool/mail/sunward
PATH=/home/sunward/webapps/rails_eval/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/sunward/bin
PWD=/home/sunward/webapps/rails_eval
LANG=en_US.UTF-8
CATALINA_OPTS=-server -Xmx300m
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/sunward
LOGNAME=sunward
CVS_RSH=ssh
SSH_CONNECTION=107.5.46.133 53789 75.126.149.5 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
MAILFROM=root@web324.webfaction.com
RUBYLIB=/home/sunward/webapps/rails_eval/lib
G_BROKEN_FILENAMES=1
_=/bin/env

Could there be anything relevant in that G_BROKEN_FILENAMES=1 report?

(24 May '15, 01:32) kenatsun

That doesn't seem to be the same error you were getting previously. Now you're getting:

[sunward@web324 rails_eval]$ rails generate controller welcome index
Usage:
  rails new APP_PATH [options]

... which suggests that rails doesn't understand the command you're giving it. Does "rails -v" show the version you expect (and the same version you're running locally where you've already done this successfully)?

(24 May '15, 02:05) ryans ♦♦

Here's what I got from bin/rails -v:

[sunward@web324 rails_eval]$ bin/rails -v
/usr/local/lib/ruby21/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'railties' (>= 0) among 8 total gem(s) (Gem::LoadError) 
from /usr/local/lib/ruby21/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec' 
from /usr/local/lib/ruby21/ruby/2.1.0/rubygems/core_ext kernel_gem.rb:53 :in `gem' 
from bin/rails:22:in `<main>'

BTW, the Rails version per the Control Panel is 4.2.1 (nginx 1.6.2/Passenger 5.0.6/Ruby 2.2).

I have also tried the same scenario in another WF account, just to see if there's something screwed up in the account I've been using. Apparently not; I get basically the same results:

    [winter@web307 rails_instance]$ cd blog
    [winter@web307 blog]$ restart
    [winter@web307 blog]$ bin/rails generate controller welcome index
    Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2 
    [winter@web307 blog]$ gem pristine  binding_of_caller --version 0.7.2
    Restoring gems to pristine condition...
    Building native extensions.  This could take a while...
    Restored binding_of_caller-0.7.2
    [winter@web307 blog]$ bin/rails generate controller welcome index
    [winter@web307 blog]$ cd app/controllers
    [winter@web307 controllers]$ dir
    application_controller.rb  concerns
(24 May '15, 18:23) kenatsun
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108

question asked: 22 May '15, 18:44

question was seen: 3,180 times

last updated: 01 Jun '15, 20:05

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM