I am relatively new to dealing with command line issues, compiling programs, and UNIX. Coming from a PHP background, I just fired off MAMP and never worried about this kind of stuff.
I am diving into Rails, and running into some issues. I tried to create a .bash_profile in my home directory to create some shortcuts for myself. I added /usr/local/git/bin to my .profile file, but it seems to have no effect on my PATH variable inside a new terminal window (i.e. it only lasts the session).
The .bash_profile seemed to persist across logins, but once I had that setup, Rails stopped working as expected! I would run rails server in my application's root directory, and Rails would create a new app called 'server' with another directory tree inside my existing app. It does this even with an empty .bash_profile. But I delete the .bash_profile, and everything works like normal.
I am in over my head here - I have very little understanding of how this all works. Any advice on where to look? Or am I missing something obvious?
Post what you added to your .bash_profile. To pre-pend something to your path the syntax is:
export PATH=/usr/local/bin:$PATH
to append you swap the "/usr/local/bin" and $PATH
export PATH=$PATH:/usr/local/bin
After you make changes to your .bash_profile you can make them available in the current terminal session by running source .bash_profile. Then if you run echo $PATH you can see the updated PATH. You should try running rails --version in your different configurations to see if the version is changing. That may account for your odd behavior.
also checkout:
path-helper as extend PATH is sooo 2010
Related
I previously asked a similar question with regards to cloud9, but I am now trying to do the same project in parallel on my windows 10 machine because I will not have internet access to use cloud9. I am trying to set up the configuration in preparation for following Daniel Kehoe's learn-rails tutorial book, but I am having trouble setting up the environment variables. The book seems to explain how to do it on Mac but I can not find the file in the atom editor. the book says to type the command:
atom ~/.bash_profile
However this just creates a new file that is not part of my rails app project directory. i have also tried
atom ~/.bashrc
which is the alternative but with the same result. It just creates a file unrelated to my project. The file is supposed to already exist somewhere.
I am supposed to put the environment variables into a file called ".bashrc" but I don't know where to find this file as it is hidden. How can I locate and open this file with Atom text editor?
.bashrc , .bash_profile are used in unix based operating systems for the terminal. In windows you set environment variables differently. In windows 10, search for environment variables in start menu, and select Edit the system environment variables and set them from there.
PS: You can have .bashrc if you have installed something like git bash, cygwin bash or bash for windows 10 or something else. And all 3 handle .bashrc differently.
Typing echo ~ in the Git Bash terminal will tell you where that folder is which contains the .bashrc file
I was having some trouble installing the gem libv8. Apparently I need to have python installed. I installed Python and was attempting to update my path with command from another forum:
SET PATH=C:[Ruby Directory]\bin;C:[Python Directory]
or in my case:
SET PATH=C:\Ruby192\bin;C:\Python27
I am not strong with paths and I can't figure out what I did. Now my environment can't find my Ruby directory.
Can someone explain what I did and how I might fix it?
That is most likely because your PATH variable already had a bunch of stuff that you simply throwed away with that line:
echo %PATH%
# a bunch of stuff
SET PATH=C:\Ruby192\bin;C:\Python27
echo %PATH%
# C:\Ruby192\bin;C:\Python27
You can try to append to it instead instead:
set PATH=%PATH%;C:\Ruby192\bin;C:\Python27
echo %PATH%
# a bunch of stuff plus C:\Ruby192\bin;C:\Python27
This change will be avalid for your terminal session only. Closing it and open again should restore the default path. If you need to make it permanent, you need to change your path throught the windows (for example, following this instructions)
It's pretty weird, but i got my PATH corrupted after installing rvm on Mac OS. I really don't understand why but i get command not found in every command i type, from 'port' to 'git'. That behaviour is really really weird, do you have any idea why this happens ? ( i installed using this : http://beginrescueend.com/rvm/install/)
It sounds like your .bash_profile was overwritten or somehow changed. I assume you have git installed as a macport. My guess is that the path to all macport installed executables was removed from your $PATH variable.
Make sure that you have the following line in your .bash_profile file:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Yes. Unfortunately the rvm installer DOES overwrite the contents of .bashrc and .bash_profile.
Happened to me too, but luckily I had a back up .bash_profile with all of my aliases, functions, and path defns.
Something needs to be fixed here.
I am attempting to take a whack at creating my first Rails application template and I am running into a slight issue with the copy_file method.
First some background.... Apparently the Ruby OpenSSL package does not ship with a CA store, so any attempt to connect to an HTTPS service will fail out of the box. The way around this(for Rails 3 apps) is to add the line OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE to the top of your config/environment.rb file. I need to do this on the fly in my template so I can install jQuery.
So I have that all figured out, my general thought is to:
Make a backup of my config/environment.rb file.
Prepend the data to original
Run the jquery:install --ui task
Restore the original config/environment.rb file.
See my template Gist, Lines 25..34 is the relevant section.
So all of that works until step #4 which fails with Error: Could not find "env.orig" in any of your source paths on line #31.
This is VERY perplexing to me because line #28 works, I can see the env.orig file on disk, so why won't the reverse work?
What am I doing wrong?
Update 1:
After looking at the Thor source thor\actions.rb it became clear that Thor uses different paths (not your current project path) for the source and destination. Furthermore my copy was actually not working, it was actually coping the ERB template file, not the already generated file.
After a breather it occurred to me use the right tool for the job so now I have: run 'cp environment.rb environment.~' and run 'mv environment.~ environment.rb' which works just fine. I am fairly certain this would not work on a windows box without the unix tools installed, but I can live with that. Does anyone have a better way?
See my Update for a Why, but the solution was to use the right tool for the job so now I have: run 'cp environment.rb environment.~' and run 'mv environment.~ environment.rb' which works just fine. I am fairly certain this would not work on a windows box without the unix tools installed, but I can live with that.
I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries in my ~/opt/lib directory. I have to put them here because I don't have root access.
I can boot up my app in ./script/console and it sees them libraries just fine because I updated my .bash_profile's LD_LIBRARY_PATH environment variable to include ~/opt/lib.
I've tried putting ENV['LD_LIBRARY_PATH'] = '~/opt/lib' in my environment.rb file but it doesn't seem too help. I get the following error from Passenger when I navigate to my site:
libodbcinst.so.1: cannot open shared object file: No such file or directory - /home/username/opt/lib/odbc.so
Anyone have experience with this?
Thanks
I had similar issue with Passenger that I described in http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/
But in your case this migth not work as you will not be able to change Dreamhost's httpd.conf file.
Other thing that you can try is to set LD_LIBRARY_PATH in .bashrc - according to http://www.wavethenavel.com/jonathanpenn/2008/09/08/bootstrapping-a-dreamhost-account-for-rails-and-git/ this has worked in Dreamhost's case. Have not verified that Passenger will execute .bashrc before launching ruby.
Using .bashrc won't work, as the library path that Passenger uses is the one that Apache loads on boot. There is no way it would look at a user's directory as that would be a major security issue.
The environment.rb way sounds like the way to go, though you might want to append to LD_LIBRARY_PATH instead. Also I'd make sure to use the full path to that directory just in case.
Alternatively you might be able to use .htaccess directives, similar to what is described # http://wiki.rubyonrails.org/rails/pages/HowToUseOracleWithFastCGI
This is an old thread, but for completeness this is how to achieve your goal:
Do not set the LD_LIBRARY_PATH if possible - it's horrendous.
As you do not have control over the environment that the Apache
user's environment, attempting to set a LD_LIBRARY_PATH env var per
the methods above will not work anyway.
Set the LDFLAGS environment variable with link and record path flags set prior to compiling the library files to set the correct search paths - e.g.:
export LDFLAGS="-L$HOME/opt/lib -R$HOME/opt/lib"
Once compiled, the files will have the correct links set to the relevant libraries. You can check this using the ldd command line tool - e.g.:
ldd /$HOME/your/custom/complied/library/file.so