I'm very new to terminal, and UNIX command line stuff. I had Rails and Ruby set up nicely with the latest version, and created a new Rails project using the rails new command.
Then I decided to look like a hacker, and use the homegrown skin. After loading up a new window, my ruby -v generated 1.8.7, instead of 1.9.3. Rails is no longer a command.
Here is the PATH for the terminal window that has what I want:
PATH=/Users/felix/.rvm/gems/ruby-1.9.3-p0/bin:/Users/felix/.rvm/gems/ruby-1.9.3-p0#global/bin:/Users/felix/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/felix/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:.
I tried looking at those files to see which ones has the path I want. But that lead down this dark and convoluted path that I probably never want to go down again. Are PATH vars supposed to be this long?
This is the PATH for the new terminal window:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/felix/.rvm/bin
There are also many other differences when I run env, but I won't go into those details (unless they are required) because I feel like fixing the PATH var would fix the other missing vars as well.
So what can I do to remedy this problem? How do I make these variables stick. Also, is my PATH var comically long? Or is this standard.
Nawww, my PATH environment variable is longer than yours. It sounds like you just need to get accustomed to setting things up in the shell you are using.
Find any article on Google that talks about bash and MacOS, and you'll probably find a bit that talks about .bashrc as well.
Like this article.
As for making a permanent change to Ruby, I found this article which says you can use "rvm --default use 1.9.3" and that setting should persist.
Related
So... I've been trying to start developing Rails, and I'm having a horrible time setting up my environment.
Installed Ubuntu 12.10 in a VM. Installed RVM. Installed Ruby 1.9.3. Installed Rails. Then Rails console didn't work because I didn't have readline, and I had to start futzing with rvm commands from here and from a Stack Overflow thread, only to get numerous incomprehensible errors.
And that's just me trying to get off the ground and start running. Please oh please, isn't there a ready VirtualBox VM file with a machine preconfigured for development work?
If you would just like one built for you go to: https://railsbox.io
Tutorial will set you you with vagrant/rails much like the other answers are talking about. I haven't used it but it looks solid:
https://gorails.com/guides/using-vagrant-for-rails-development
You could also simply use a remote vm that is setup and available anywhere:
https://c9.io/
There are other similar options out there.
I have used both of them and they function excellently for this purpose, they also troubleshoot well on google because you have multiple people using the same environment. If you are new to Rails/Ruby and are unfamiliar with using a nix environment I highly suggest this route. You will also be able to access them more or less anywhere through a browser.
I know it is rather an old thread but since it came up so easily in a search and the answer wasn't entirely satisfactory when I had found it previously I thought I would broaden the list of options.
Found this: https://github.com/rails/rails-dev-box
Hoping it's going to help; consistent with Branden's comment above.
If I don't have a file open from the rails project I'm working on, I can't use any rails.vim commands such as :Rcontroller, :Rmodel, :Rview (I get the error: Not an editor command).
Additionally, if i try to use :Rconfig or :Rroutes when I don't have a rails file open, I get the error: Not an editor command: :Rfind application.yml.
I'm using a pre-fab vim config so I am guessing I need to hunt down an issue in there? Or is this just the way rails.vim is meant to work?
The short answer is that this is the way rails.vim works.
rails.vim tries to detect the Rails project using the path of the current buffer. In general this makes sense because a number of the commands provided by rails.vim are specific to the current file. Also, it is very possible to open files from several Rails projects in the same Vim session, so even commands that only reference the project as a whole need to be tied to the current context.
It would be nice if the project-level commands like you describe could be available when you're in a new buffer by falling back to getcwd() and detect that the current working directory is a Rails application. But from a cursory examination of the source, I think it would require some significant restructuring of the plugin.
I wrote a plugin called Open that opens up a project using NERDTree and project the README as a default view. One of the advantages of this is that by having a file open by default, you can use any of the Rails commands immediately.
When I run rails c and press the up key when irb starts up, I can see the last commands I entered when my app dropped to irb after encountering a debugger command for the ruby-debug gem. I would not only like to clear these commands out, but I would like it if rails c would pull the last commands I issued during my last rails console session. I think it used to do this but I'm not sure what has changed. I'm on ruby 1.8.7 and rails 3.0.3 on Mac OS 10.6.5 if that helps.
Update
Ray's answer helped me out in the interim. Recently I did a bit more digging to find out more and realized that there are a number of conflicting issues.
IRB checks if you have a ~/.irbrc and if not falls back to /etc/irbrc as Ray mentioned. However, if you are using rvm there is another file to consider ~/.rvm/scripts/irbrc which just loads up ~/.rvm/scripts/irbrc.rb (note the .rb) if you have rvm_path set in your ENV (you should if using rvm).
Interestingly while ~/.rvm/scripts/irbrc.rb was based off of /etc/irbrc they are not the same and differ in a few ways. The most obvious way and easiest way to detect which one is being used on your system is their history file's name. If /etc/irbrc is being used your history file will be ~/.irb_history where as rvm's is ~/.irb-history (Note: _ vs -).
Hopefully this additional information will help you determine what you need to setup your system as you would like.
Pry Concerns
I've since stopped using debugger and have moved to pry-byebug which includes the pry gem. Pry is an alternative to IRB but can also be used along side and within it. The reason I was able to provide the above update is because I was trying to figure out how to keep their respective histories separate. For more information please see my answer to the SO question on "why does pry history keep cloberring irb history?". I've included links there to the known Github issue for Pry as well as my attempt to fix it.
I interpret you question as asking how to turn history on in the Rails Console and off in the Ruby debugger. If this isn't true, please clarify.
IRB, and by extension, the Rails Console, read from ~/.irbrc, or if that doesn't exist, /etc/irbrc, to startup and configure irb. Your history is typically written to ~/.irb_history, but that is dictated by the contents of your irbrc file. The /etc/irbrc on my Mac OS X is set up to write the history from irb, so perhaps you've created a local .irbrc that doesn't have history, or perhaps you have a syntax error in that file.
The debugger reads a file called .rdebugrc on startup. You can turn off history in debug by adding this line to ~/.rdebugrc:
set history save off
Turn it back on with:
set history save on
You could also set your debug output to go to a different file than irb reads from with the command:
set history filename
These also work from the debug prompt, but aren't persistent.
There are a number of tools to help improve the irb experience. Bond and hirb are promising.
Here is Comprehensive list of Irb Tools and some tips on directly editing the .irbrc file.
Hope this help!
Although a very old question I got here by google.
Turns out RVM slightly changed over time.
Currently my IRB history (using rvm) is stored here:
user#host:~$ ls ~/.rvm/rubies/ruby-2.4.2/.irbrc*
/home/user/.rvm/rubies/ruby-2.4.2/.irbrc
/home/user/.rvm/rubies/ruby-2.4.2/.irbrc_history
I'm interested to play around with RoR a bit. Apart from literature i should read, i'm particularly interested about how to setup development environment.
Here's a good example how to setup environment for Java from Noda Time project wiki pages.
I want something similar but for RoR.
As far as i know - unix operation systems fits way much better (have toyed on windows 1 1/2 year ago - pure nightmare). So it would be nice to get some recommendations about linux distros and how to make it run next to win7/xp.
Basically - i want to shorten endless searching and improvisation until i can play with some code.
P.s. bonus for simple sample project. :)
The single quickest way to get up and running might be to simply grab Netbeans and develop against its built-in JRuby instance. It will walk you through setting up a Rails project and even give you some nice-to-haves like autocompletion.
Baring that, the easiest method is likely to download a Linux VM Appliance pre-Customized for Rails Development and a copy of VMWare Player.
The best 2 ways to go are OS X and Linux, I use Ubuntu just because it's the nicest package that I've found (there will no doubt be a variety of opinons on this.)
For Rails, I like to not use the packages or pre-installed versions, and instead build my own so I can test against various versions of ruby if need be. Hivelogic has a nice post about how to do it for OS X 10.6.
From there, you can just run:
rails myproject
cd myproject
./script/generate scaffold post title:string body:text
rake db:migrate
rm public/index.html
./script/server --debugging
And then connect to http://localhost:3000/posts to get to your application.
Once you get more comfortable, check out running Passenger instead, so you can have multiple applications running at the same time. On OSX there's even a nice Prefpane to easily set up new sites. This also ins't too hard in Ubuntu with the examples provided in the passenger docs.
For editing the application I think the IDEs (Aptana, Netbeans, etc.) are still too heavyweight, especially for small starter projects. I like Textmate (like everyone else) for OSX and gedit with gedit-mate.
Once you're writing applications, you'll find that railsapi has the best interface for browsing all of the various methods not only in Rails, but ruby, authlogic, and a bunch of other common gems.
Lastly, you'll want to look into source control, with git being preferred in the Rails community at the moment.
Good luck!
Get VMWare player
Get ubuntu vm
If it's server version - install desktop x or whatever it's called
Mess around with sudos, visudos
Mess around with vi editor to save newly created account to sudoers list
Mess around with vertical mouse scrolling which apparently does not
work on vmware+ubuntu
Finally install netbeans
Through plugins, install ruby on rails
Some global updating
Enjoy toying
tadaaaa...
Something like that i wanted - with each point explained a bit (no doubt that my steps aren't best ones and sounds funny for those who knows).
I guess that i forgot to mention that i lack knowledge of unix systems in general too.
Anyway - got what i was looking for. :)
I am having a major issue with creating a Rails Project on Aptana (using mac os x). Basically, when i try starting a Rails project and name a file, it comes back with an error saying:
"!!! Path to log file not valid: /Users/fab/Documents/Aptana Studio Workspace/test.rb/log/mongrel.log mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help."
and then a pop up comes up saying: "Rename the directory to no longer have a space"
After all this, i tried renaming the directory without spaces, but then when i went back to create a new project again it came back with this pop up that says "resource'/fab/public'does not exist." Under this there is a list of two options: "periodic workshop save" and "replace project index file."
What does this mean, and how can i fix the problem?
Any advise would be much appreciated!
Omarj
Mongrel used to have a bug with writing log files, and for whatever reason it's trying to create a path relative to a file (rather than a folder) in your case. i think they also had issues with spaces in the path.
Do NOT rename your workspace path, or Studio/RadRails won't see the files anymore (as you saw above) - because you moved them.
I suggest renaming the folder back. This question is pretty stale, so mongrel is no longer widely used. you could try one of the other server types, like webrick.
Hey, I don't have an answer to your question. However, would advise you that if you are starting to get your hands dirty with Ruby and Rails, then consider TextMate as your IDE instead of RadRails.