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

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:
Operating System: Kubuntu 11.10
Ruby version: ruby 1.9.3p0
Rails version: Rails 3.1.3
Aptana IDE: 3.0.6
TIA
nav

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.

Supporting previous #SylvainC's answer publishing my .pam_environment file for rbenv:
RUBY_VERSION OVERRIDE=3.0.0
rbenv_path DEFAULT=/home/#{PAM_USER}/.rbenv
GEM_HOME DEFAULT=${rbenv_path}/versions/${RUBY_VERSION}/lib/ruby/gems/${RUBY_VERSION}
GEM_PATH DEFAULT=/home/#{PAM_USER}/.local/share/gem/ruby/${RUBY_VERSION}:${GEM_HOME}
PATH OVERRIDE=${rbenv_path}/plugins/ruby-build/bin:${rbenv_path}/shims:${rbenv_path}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Related

version of Ruby for cucumber

I have no knowledge in Ruby, but I need to run some tests in it. The code is in Ruby and Cucumber. I use intellij on Mac. When I first open intellij cucumber step definition where not recognised from feature file. In terminal I got:
Required ruby-2.1.2 is not installed.
To install do: 'rvm install "ruby-2.1.2"'
but
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.4.1/bin/ruby
so I run the install command as suggested and now I get
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.1.2/bin/ruby
Now my feature files connected to step definition as well. I will appreciate if anyone could explain me what happened. What prompted me to downgrade the version of Ruby and how it fixed cucumber.
Make sure you have ruby 2.1.2 set in File -> Settings -> Languages & Frameworks -> Ruby SDK and Gems
What I suspect is happening is you have run rvm use 2.1.2 in the terminal but when your IDE runs something it is using the ruby version set in the settings.
You probably have a .ruby_version file in the project root directory. This will enforce a specific version of Ruby. So the person who put it there is who to ask why the version was restricted like that. There may have been a good reason, such as that's what is being used by all your users.
It has nothing to do with Cucumber. rvm has some kind of operating system hook, I think, that runs whenever you cd into a directory. It looks for its special control fiels such as .ruby_version and .rvmrc file. This page describes this in more detail: https://rvm.io/workflow/projects.

Error installing ruby bundle in textmate

I have Textmate 2.0-beta.7.1 on Mac OSX v10.9.5
I would like to write ruby scripts so I installed the ruby bundle.
However when I try to run a script I get the error:
env: ruby18: No such file or directory
so having found that the path to my ruby installation using
which ruby
/usr/bin/ruby
I made sure this was in my variable paths in Textmate>Preferences> Variables so that it under the PATH variable name it looked like this:
$PATH:/usr/bin/ruby:/opt/local/bin:/usr/local/bin:/usr/texbin:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
I then tried to run my ruby script again and I got the same error. I have googled for hours and the only resolution seems to be the addition of the ruby path to $PATH as I have done above so I'm a bit confused as to my I cant proceed
Make sure you have not disabled the Bundle Support, TextMate, Text, Source, or SCM bundles in the Bundles tab of Preferences; these are all required bundles to support basic bundle functions.

RubyMine 3.2 failing to find libmysqlclient.18.dylib on MacOS Lion

Just upgraded to RC1 of RM 3.2 on MacOS Lion and couldn't run the application anymore. Running with rvm. On startup the mysql2 gem reported it couldn't find libmysqlclient.18.dylib on a dlopen.
Solved it. Posting the solution here so it will help somebody save some time.
Using Apple's Property List Editor create an entry in ~/.MacOS/environment.plist call LD_LIBRARY_PATH and set the value to /usr/local/mysql/lib or whereever your MySQL libraries live.
Logout and log back in and RubyMine and the mysql2 gem are happy again.
I got around this by adding this to the environment variables section of the RubyMine server instance.
1) Open Run/Debug Configurations for your server
2) Click on the "..." next to "Environment Variables"
3) Add "DYLD_LIBRARY_PATH" as the key and "/usr/local/mysql/lib/" as value (path from using .dmg MySQL install)
There have been several solutions suggested, but I think the best solution is the last one I suggest:
1) Editing Environment Variables in the Run/Debug Configuration
This works but you have to keep doing for every single configuration, which is a pain. It also doesn't fix the problem if you are running outside of RubyMine.
2) Editing the .MacOS/environment.plist
This seems to not be supported anymore in later versions of OS X.
3) Setting the DYLD_LIBRARY_PATH environment variable in the .profile/.bashrc
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/
This fixed the problem on the console, but RubyMine doesn't seem to load the environment from .profile/.bashrc.
4) Symlink the libmysqlclient.18.dylib into /usr/local/lib
This is what Homebrew typically does, which is to create a symlink for the dylib that cannot be loaded.
ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
You only need to do this once and you're done.. and it works globally, in the console and in RubyMine.
Using Apple's Property List Editor create an entry in ~/.MacOS/environment.plist call LD_LIBRARY_PATH and set the value to /usr/local/mysql/lib or whereever your MySQL libraries live.
Logout and log back in and RubyMine and the mysql2 gem are happy again.
#Aaron Chambers, couldn't add as an answer at that time. Thanks.

How to tell Terminal which version of Ruby to use?

I have two related questions that I was hoping someone could help out with.
I recently installed Ruby 1.9.2 on my Mac (running Snow Leopard 10.6.4) and I haven’t been able to figure out how to get Terminal to use the new Ruby as a default, rather than the factory-installed Ruby 1.8.7. The old Ruby 1.8.7 is located in my ~/usr/bin/ruby directory while the new Ruby 1.9.2 is in ~/usr/local/bin/ruby. Someone said that I need to put the new version of Ruby's directory in the PATH prior to the old version's directory so that the system looks there first - is this correct? If so, can anyone provide step by step instructions on how to do this?
I’ve created a new directory but can’t seem to figure out the correct way to add that directory to my PATH using the Terminal bash shell. I tried using the instructions that I found here (http://www.macgasm.net/2008/04/10/ad...thin-terminal/) twice but they didn't work for me. The directory containing my program ("Ruby_Programs") shows up in the PATH but when I try to run "ruby newprogram.rb" from the command line it results in ":ruby: No such file or directory -- newprogram.rb (LoadError)". The file definitely exists and is a functional Ruby program. I did change the name of the directory to "Ruby Programs" and then back to "Ruby_Programs" - could that have somehow caused this problem?
Any help would be greatly appreciated. Here is my current PATH:
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/sbrriffe/src:/usr/X11/bin:/Users/sbriffe/Ruby_Programs/:
You might want to check out rvm. You can install multiple versions of ruby side by side and easily switch between them. If you follow the rvm installation notes you won't have any more path problems.
Your Ruby Programs directory shouldn't be in your path: the location of your ruby interpreter should be. Then, you cd to the location of your ruby program, and run it from there: ruby program.rb.
Since you are on a Mac, check out homebrew for something that will make installing software easier. I have my homebrew set up in /usr/local, and it works great.
Once you have installed stuff where you need it, then you'll want to adjust your $PATH. The items in $PATH are searched in the order they appear, so in your ~/.bashrc, you'll want to add:
export PATH=/usr/local/bin:$PATH
To make sure /usr/local/bin gets searched before /usr/bin.
I would use RVM to get everything installed, and then once you have RVM installed it is easy to set your default Ruby version.
Check out https://rvm.io/ -- once you have that installed you can change your default by using : $ rvm use 1.9.2 --default
hope that helps- you can do this with any version, not only 1.9.2

Getting Textmate to recognize Ruby version upgrade

I used the instructions at http://bparanj.blogspot.com/2010/06/installing-ruby-191-on-snow-leopard.html to install Ruby version 1.92 on my Mac running Snow Leopard. The only deviation is in step 3, which calls for .bash_profile to be updated. I have .profile, but not .bash_profile, in my home directory, so I added the export command to the last line of .profile. The installation completed successfully (with the same two warning messages as mentioned, which I too disregarded), as Ruby -v in a terminal prints
ruby 1.9.2dev (2010-07-02 revision 28524) [x86_64-darwin10.4.0].
When I run Textmate, however, cntrl-R invokes Ruby version 1.8.7, as it did before the 1.9.2 installation. In Textmate's Preferences-Advanced-Shell Variables, TM_RUBY is set to /usr/bin/ruby. The (binary alias) file 'ruby' has not been updated. What is the easiest way for me to instruct Textmate to use the newer version of Ruby? Please note my understanding of OS X is relatively limited.
What is the easiest way for me to
instruct Ruby to use the newer version
of Ruby?
I believe you mean "What is the easiest way for me to instruct Textmate to use the newer version of Ruby?"
Assuming that is the case, have you tried to edit the TM_RUBY shell variable to point to your newly installed version? According to the docs you referenced, it should be somewhere under /usr/local (most likely /usr/local/bin/ruby).
You can find out the location of your ruby installation by typing the following in your terminal window:
$ which ruby
/usr/local/bin/ruby
then perform the following to verify the version
$ ruby -v
Once you have the proper ruby path, in Textmate, double-click the 'value' of the TM_RUBY shell variable & type in the path to your 1.9.2 install.
Why not just create a .bash_profile file in your home directory?

Resources