I have an app running on my localhost which I want to install on my hosting account. The host is Bluehost and they appear to support RoR, as evidenced by this tutorial which I am trying to follow precisely.
The thing I'm stuck on is where my ruby gems should be? I'm currently unable to bundle install even immediately after gem install bundler so I'm pretty sure my app is looking in the wrong place. But before I can correct that, I think I need to know what is the right place.
Currently it appears there are gems here:
~/ruby/gems/gems
This is my app's /config/environment.rb file:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Goodwatching::Application.initialize!
ENV['GEM_PATH'] = '/home5/secretde/ruby/gems/gems:/usr/lib/ruby/gems/1.8'
Currently I can install a gem like this gem install bundler and it succeeds. But then afterwards I try bundle install and it says to intall bundler first.
The bundle installfail means that you are unable to find the path to bundle executable.
Your PATH must to include the path to bundle executable.
You could tray something like ~/ruby/gems/gems/bundler/bin/bundle install to workaround the path problem.
Related
I'm trying to create my first rails app. I'm on a Macbook Pro, so macOS.
I've been following this guide setting up rbenv, rails etc.
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos
Then I'm following a crash course on YouTube. In the terminal I try to create a new rails app
rails new foodlog
It starts to set up in the folder I made for it, but the following happens during setup
Bundler::PermissionError: There was an error whle trying to create
'/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/racc-1.6.0'.
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'
This error continues repeating the same thing with things such as "strscan".
Then after it says
In gemfile:
rails was resolved to 7.0.3.1, which depends on
actionmailbox was resolved to 7.0.3.1, which depends on
net-imp was resolved to 0.2.3, which depends on
stscan
run bundle binstubs bundler
Could not find gem 'sprockets-rails' in locally installed gems.
rails importmap:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems.
rails turbo:install stimulus:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems
I've tried looking online, coming across similar but not exact issues. For example, one solution suggested doing bundle install in this directory, versus where the guide says do it in the home directory. So I do that and get
Bundle complete! 0 gemfile dependencies, 1 gem now installed.
Still doesn't do anything. I think the main culprit is the permissions error it mentions above? This is my first time trying to really do any development on the macOS and I'm sure there's just a misunderstanding somewhere regarding permissions, so if anyone can help that would be appreciated!
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'
Your question does not mention, so I think you might have missed this suggestion. Make sure all directories have the executable permission
I'm trying to deploy a rails app under apache (on Ubuntu 11.04) for the first time and I'm running into some issues. Basically, when I hit the site, I get an error:
no such file to load --bundler
I'm running rails 3.0 under apache and using passenger. Currently, the app lives under a subdirectory of a user directory. I've installed rvm and have pointed apache at the directory. I did a bundle install to install all the gems.
However, I think I may have screwed up by putting the site in a user directory. Should I move it somewhere under /var/www? I'm thinking that it is entirely reasonable that apache is not getting the same gemset that I have installed for the user. What do I need to do to get the user that apache is running under to have the same rvm capabilities?
I'm a bit clueless on what information you guys need to help me, so please clue me in.
Did you install the necessary gems for Rails? Install bundler by executing gem install bundler. Then go into your Rails app and type bundle install.
Also, after bundler is installed, type which bundle to see if it's in your $PATH.
After finally managing to get my Rails app working, I've got stuck with a slightly perplexing problem. I've deployed my Rails 3.0.5 app to a Ubuntu 10.10 server with Capistrano, RVM and Nginx. All is working nicely and I can confirm Rails is working as I'm getting data from the database and meaningful log messages.
The problem is that on the server, I can't access the console. When I try
rails c
It says "The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'"
However it is installed otherwise my application wouldn't work! I've only got two RVM gemsets installed, the global one and one called "rails305". Trying
rvm gemset use rails305
then
gem list
doesn't show any of the gems that my app needs, however they must be installed because 1) the app wouldn't work without them and 2) in my Capistrano deploy script, bundler installs them (to that gemset). So the problem is obviously something to do with RVM but I can't work out what it is... anyone any ideas?
It looks like Capistrano uses bundler so you might want to try
bundle exec rails c
from the deployment directory.
See the Bundler deployment page for more information.
Bundler by default doesn't install gems into the default rvm environment when deployed via capistrano, it installs to the "shared/bundle" directory instead, to try and accommodate production installation environments that aren't using RVM. If you are using RVM in production, and want to just have bundler install to your default ruby/gemset (which is terribly useful if you are going to be logging into the production, running rake scripts, console, etc), add the following options to your config/deploy.rb:
set :bundle_dir, ""
set :bundle_flags, ""
This will remove the "--deployment" (and "--quiet", which you may or may not want to keep) and --path flags which cause bundler to try and package everything up nicely, so bundler will now install to the user's RVM environment; making your server environment work a lot more like your dev environment (which can be good or bad depending on what your needs are).
ubuntu 10.04 slimy lynx or whatever it's called is the OS for a production app. I've installed rvm too, and other then being on a mac, the dev and production rubies and gems are the same.
Now, I'm used to seeing all of the bundled gems in gem list... like normal, however when i do gem list in production, I am not shown any bundled gems.
This means i can't use rails c or any other gem.
I've found out that i can do bundle exec rails c or something and use the console that way, but I'm more interested in why this is happening, and how to fix it so gem list has all the gems. it just feels right.
Thoughts?
When in development mode on your mac, the gems still get installed in the default gem path, whereas in production mode, they get installed in a folder specific to your project. Try doing a bundle show rails on each machine and you'll see what I mean.
When you run gem list it looks in the main gem folder, and since your production gems are sitting in a project-specific folder, the global gem command doesn't know to look there. So you will need to do a bundle exec to run any of those project-specific gemscommands on the server. For my purposes, I created a be alias to bundle exec. Also, to list your project's gems, you can do bundle list.
See http://gembundler.com/v1.3/rationale.html#deploying-your-application for the rationale behind this.
This is a production server. I have Passenger installed and it works properly for the most part. However, I always have to pack the gems with the projects. If I don't, I get this error message:
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
gem list --local returns rails 2.3.8 as well as 2.3.5 so the gem is actually not missing. Since I could not resolve this issue, I keep including the rails gem in every project (which results is a properly working application).
Any ideas?
P.S I did try the suggestions of the error message, my config is asking for 2.3.8 which I have installed
Make sure you are installing/running the gem command with the same user permission as Passenger.
By default, Passenger runs inside Apache which has superuser privileges.
If you type gem install, the Gems will be saved in your user folder unless you are root.
If you're installing gems logged in as a normal user (non-root) or without using sudo, your gems go into .gems folder in your home directory (eg. /home/matt/.gems) and Passenger cannot find them.
You can either install them as root/sudo or add your local directory to your GEM_HOME/GEM_PATH. Not sure if this is the best solution, but I put this at the top of config/environment.rb in my application:
if ENV['RAILS_ENV'] == 'production'
ENV['HOME'] = "/home/matt"
ENV['GEM_HOME'] = "/home/matt/.gems"
ENV['GEM_PATH'] = "/home/matt/.gems"
end