ruby-on-rails-3.1aptana

Aptana Studio 3 tries to create new project with "rails ." instead of "rails new ." on update of rails


I am using Aptana Studio 3 and having trouble creating a rails project in the IDE. Aptana tries to create a new rails project using the command rails . instead of rails new .

I used the solution at:

Cannot create a new Rails Project with Aptana Studio 3

involves installing ruby then rails and then Aptana which rectified problem until I updated rails using gem update. This made Aptana repeat the behaviour above and did not create the project although, rails -v shows the expected version. What was shown on the Aptana console was the rails usage help text.

Is there any way to make Aptana use the correct syntax and/or version of rails even after updating the rails version?

I obviously do no wish to go through the whole installation again and believe that there is some configuration setting I am missing.

FYI my configuration details are:

TIA

nav


Solution

  • It's an issue with environment variables. The Aptana Getting Started Guide mentions that:

    You should also make sure that your login PATH is set up correctly such that you can execute the ruby, gem, rails, and git commands correctly. Setting these things up in your .bashrc (or equivalent) isn't sufficient, because it doesn't get evaluated by default when GUI applications like Aptana Studio 3 get launched.

    So the problem must be that Aptana doesn't see the right path and/or environment variables. I have Kubuntu 11.04 64-bits and Kubuntu 11.10 32-bits and the problem shows on both machines using Aptana Studio 3.0.8. How to set the "login PATH" then?

    In the Ubuntu family, and any Linux distribution that uses Linux PAM, session-wide environment variables can be set with a .pam_environment file in the home folder. (KDE also offers a way to set session environment variables, but setting a .pam_environment is sufficient).

    But only setting the PATH environment variable does not work (I've tried). You must also set GEM_HOME and GEM_PATH.

    The .pam_environment file has a very specific syntax. I'm using rvm to install Ruby and Ruby on Rails. So here is my .pam_environment file:

    RUBY_VERSION OVERRIDE=ruby-1.9.3-p0
    rvm_path DEFAULT=/home/sylvain/.rvm
    rvm_bin_path DEFAULT=${rvm_path}/bin
    GEM_HOME DEFAULT=${rvm_path}/gems/${RUBY_VERSION}
    GEM_PATH DEFAULT=${GEM_HOME}:${GEM_HOME}@global
    PATH OVERRIDE=${GEM_HOME}/bin:${GEM_HOME}@global/bin:${rvm_path}/rubies/${RUBY_VERSION}/bin:${rvm_bin_path}:${PATH}
    

    You'll note that even though I'm using rvm, these variables fix a specific version of Ruby and gemset.

    You must adapt those values for your own environment. Note that I used variables that rvm sets in .bashrc: RUBY_VERSION, rvm_path and rvm_bin_path. I could have only specified GEM_HOME, GEM_PATH and PATH, but then the result wouldn't have been DRY. ;-) In other words, I would have had to duplicate paths. Note that I didn't use the HOME environment variable, because it doesn't seem to exist outside of the shell.

    After rebooting, I've tried creating a Ruby on Rails project, as well as generators (Commands menu > Rails > Call Generate Script with Controller and Model) and it works, at last, when I start Aptana Studio 3 from a desktop shortcut.

    And finally, the Getting Started guide states that:

    If getting your login PATH set up in this way isn't practical for you, you can work around the problem by launching Aptana Studio 3 from the command line, using the studio3 command line utility.

    Since opening a console and typing {my_path_to_aptana_studio_3}/studio3 is a hassle, I first tried making a desktop shortcut to "/opt/aptana3/studio3", "konsole -e /opt/aptana3/studio3", or "bash -c /opt/aptana3/studio3"; nothing worked.

    So I tried putting an alias in my .bashrc file, so I wouldn't have to type the whole thing from a console everytime: alias aptana="/opt/aptana3/studio3"

    It didn't work either. I realized that in order for the command to work, it must be executed from the Aptana folder. So the following worked:

    alias aptana="cd /opt/aptana3 ; ./studio3"
    

    UPDATE: The .pam_environment solution does not work for Kubuntu 11.04 64 bits, so I assume it would not work for Ubuntu 11.04 either. However, for Kubuntu, setting session-wide environment variables for GEM_HOME, GEM_PATH and PATH in a shell script in ~/.kde/env works.