How do I find the full installation path of a gem in rails.
bundle show gem_name
gives
/var/lib/gems/1.9.1/gems/gem_name-version
My problem is, what directory is the 'var' folder in? I've tried looking in C:/Ruby but it's a really large folder and I don't want to spend all day manually combing my hard drive.
On Windows, you typically find them back in (depending on your ruby version)
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems
From within your Rails application, you can also run
Gem.loaded_specs['gem_name'].full_gem_path
Related
Trying to run a project that was provided by a client.
I have the correct versions of Ruby, Gems, Rails, Bundler, Homebrew etc installed.
When I run rails server I get the following error in terminal.
.rvm/gems/ruby-2.2.2/gems/airbrake-ruby-1.0.4/lib/airbrake-ruby.rb:288:in `call_notifier': the 'default' notifier isn't configured (Airbrake::Error)
After much time spent on Google I couldn't find a fix on this.
Here is a screenshot of the whole terminal error message which I get the feeling these other lines could be related.
It looks like a previous developer may have hardcoded a commit hook in the application, pointing to a file in their local .git folder (and which you don't have).
I'd recommend either asking the developer to provide the missing file, create a dummy file in the same place, or removing that line.
Recently I have noticed that trying to bundle without the "sudo" command almost always results in something like:
Could not find gem 'faye (~> 1.0.0) ruby' in the gems available on this machine.
but using sudo bundle install works like a champ.
Why would my computer be doing this?
Note
I don't really know what extra information to provide, so feel free to request anything.
With "sudo" the command is executed by the root user. When executed like this, it also includes that some environment variables are set differently, because they are needed in the context of the root user.
This might be what's happening here, that since possibly the PATH variable (or some other environment variable) is different in the sudo-environment, it can actually find the gem it is looking for. While in your normal execution environment, it can not find it, since the PATH is set differently.
Hope this helps :)
Following up on #topedro's answer: You're seeing this error because you did some actions as root, and some as another user.
Most people avoid this situation by installing Ruby and all gems as the same user who'll be executing them. E.g., your personal user account, or one set up for this purpose on a server named (usually) "deploy".
An easy way to get started from your current broken state is to install RVM as a non-root user, and go from there. You could also download the Ruby source and compile it yourself instead of using RVM.
Whatever you do, treat Ruby and the gems as simply some app owned by a non-root user, residing in that user's home directory.
I'm not a RoR programmer myself, but a good client of ours has sent a project their previous web team built and I need to get it up and running on their server.
The server uses cPanel and Ruby on Rails is already installed. I've created a project via the cPanel wizard and located the file tree via SSH.
Using SSH, I've tried to replace this file tree with the project I've been sent, but when I hit 'run' in cPanel, the application doesn't actually start (although the success message would indicate that it has).
If I leave the original cPanel-created application in place, I can run/stop no problem and the web interface at :12001 opens up just fine.
I assume there are either conflicts with RoR versions that I need to resolve, or there's simply more to it than just replacing the file tree? Again I'm not a RoR programmer and I'm having a hard time finding a migration guide that tells me anything other than "set up in cPanel and replace the files".
I'd very much appreciate either some genuinely useful links to RoR application setup/migration guides (ideally for cPanel) or a step-by-step answer please.
First, forget Cpanel for now. Try in one environment where you can control everything.
Try to know better the rails version used and the associated gem19s or plugin if from 2.x days. The ruby version is important too, only then you can start defining a plan.
I'm afraid you won't get a step-by-step answer, but I'm sure you can be pointed in the right direction by providing the requested information.
Simple questions: Do you have a Gemfile file at the top at your project? Do you have any plugins (stuff in vendor/plugins)?
Update:
With the Gemfile provided here are the required steps:
Install ruby (if you haven't install it using rvm. The version 1.9.3-x should be the safest.
Install rubygems
Install bundler
Go the project dir and run bundle install
run rake db:migrate (assure you have the database setup acording to config/database.yml
run rails s and check the logs and see if the server is up.
If after installing bundler, you don't have the bundle command in your path, you need to add this your .bash_profile:
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
I'm trying to customize and modify Spree Commerce, but none of the standard asset files/images/views are available under either app/views, lib/assets, or anywhere else I can think to look. I'm trying to go through their tutorials, but I can't find anything to edit. Is there another command I need to decompress everything or something? Thank you so much for any help!
The way I over came this is to download the main spree gem, via github.com, look where the images are located then creating the images I wanted to override in my local app/assets directory with the same path run:
rake assets:precompile:nondigest
restart webrick/pow or any other web server you are running and voila!
I'm guessing you're not really familiar with how gems work. As people here have said, these are not going to automatically show up in your core app directory, but the gemfile and running bundle install knows how to reference them.
So you need to find those gems to figure out the file names, as you said. If you want to view the gemfiles run this command in the terminal:
$ bundle open spree_frontend
If you get this error:
To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR
then you haven't set up the editor, so do this:
export BUNDLER_EDITOR=sublime
Then redo the bundle open command. This should open the spree_frontend directory which will let you investigate the file names/paths and the assets. If you want to change an entire template, you need to create that file matching its name and path exactly as it is in the spree gem (spree/layouts/spree_application.html.erb for example) then when you edit it your rails app will render the code in your core app directory thus overriding the spree gem.
That make sense?
Trying to understand this open source app on github, it has a gem file:
https://github.com/bestbuyremix/BBYIDX/blob/3f8d378ef318544411aa887c4ef71e1ab8a9efd0/.gems
And a plugins folder:
https://github.com/bestbuyremix/BBYIDX/tree/3f8d378ef318544411aa887c4ef71e1ab8a9efd0/vendor/plugins
Why would you want to do this? Does this make upgrading the plugins harder?
When you reference a gem, from what I understand, it downloads the files and stores them at a global level (gemset if using rvm etc), so I guess loading it as a plugin gives you access to the source to modify?
i.e Why go with gem versus a plugin or visa versa?
Plugins give you the flexibility of being able to just copy your app somewhere else and poof! it's all ready to go.
Gems on the other hand, force you to a) download them to every single piece of hardware that your app is running on via rake gems:install and b) force you to keep track of which packages are installed on which system.
With plugins, you know that when you stick it in your vendor directory, it will work immediately.