Why can't I start my webserver (`rails server`)? - ruby-on-rails

I've created a new rails app using rails composer (https://github.com/RailsApps/rails-composer). however when I start my rails server (WEBrick), I get the following error:
~/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Permission denied
I've looked at this question and tried the steps in the selected answer but I'm getting the same issue. This seems like a conflict between RVM and Bundler since I've got ruby-1.9.3 as the top level directory and 1.9.1 as an intermediate directory. Not really sure what that means.
Any help is greatly appreciated.

This is generally the result of some directory in your Rails directory not having the correct permissions.
Here is an in-depth discussion of the permissions in Rails: https://stackoverflow.com/a/6091058/1669208
If you wanted to check to see if that was the problem. Then on a NON-PRODUCTION SERVER give 777 access to the entire rails directory.

Related

"rails new [Blah]" No such file

So I'm new to Ruby and also to Rails. I have recently installed Ruby on Arch Linux.
It was mostly all fine any happy except for a few errors here and there but now when I try initializing a new rails app using rails new AppName I get the error
bash: /home/[username]/.gem/ruby/2.3.0/bin/rails: No such file or directory
I've tried creating a file and directory called rails in but get more errors.
reinstalling rails same outcome
reinstalling ruby same outcome
following any other dependencies at install also leads no wear.
Ask for any info you may need.
Thanks in advance
UPDATE
installing of gems is now stopped by a common error
$ gem install rails
Building native extensions. This could take a while...
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /usr/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out
and the same when I try install nokogiri
ok first check that you installed both ruby and rails well
ruby -v
and
rails -v
so if you get a respond to that you're all good
go to the place you want to create your folder att
rails new appname
then
cd appname
if that doesn't work try to generate anything
rails generate controller appname
if the generate works then your rails is ok if not then you might want to add the rails to your environment variable path.
You installed ruby on your computer. However the path is not recognized yet on it. To add it you can do this . if you are using windows my computer right click and then chose advanced system settings -> advanced at the bottom environment variables system variables PATH and then add the the path to your ruby bin folder. I am sorry i don't have enough reputation so can't add pictures but reading this will solve your problem
The overall problem is a lack of permissions to /usr/lib/ruby/. This can be fixed with
sudo chmod 777 /usr/lib/ruby

Where do you run "gem install bundler" to make your own gem?

I'm trying to make my own gem, but I don't know where to run "gem install bundler" in my terminal. And when I ran it in my directory where I have all the other rails projects in it, it first said Permission denied # rb_sysopen /Users/km/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/.codeclimate.yml
so I decided to chmod this .codeclimate.yml file to 755, but it still gave me the same error so I did chmod 775, and now it gave me this error:
Operation not permitted # chmod_internal - /Users/km/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/.codeclimate.yml
I have no idea what I'm doing. I am new to unix commands and rails and still have no idea what this file even is or what permission I need to change. Can someone help, please?
Generally, to achieve some sorts of structure I created different workspaces for my projects. So I have a folder for gems, templates, projects.
In your case, I don't think you should be trying to modify the permissions on your workspaces, rather create a work directory where you have permissions to.
Since you mentioned that you had a project you had your other rails projects in, I'd assume you already have bundler installed.
To create your gem IMHO, you should:
Create a directory for your gems
Run bundle gem name-of-your-gem-here
If you navigate to this project folder, you should see the boilerplate for your gem has been generated.
Hope I was able to help.

Rails Server Error - Fail after Gem Update

I was trying to make a contact form using this site
I made it to mount ContactForm then ran bundle update and bundle install. Now I am unable to start the rails server. I get this error:
Error: Command not recognized
Usage: rails COMMAND [ARGS]
I have used git to checkout my last working copy of the app but I still am unable to start the rails server and have tried searching for answers online, unsuccessfully. Please help. I do not know how to continue to work on my website.
Thank you.
No need to respond. I tried first updating my Gemfile to the specific versions I know I was using before the rails server failed to respond. I had no luck there. Then I just uninstalled every gem and reinstalled them all and was able to get it up and running again. Mystery to me, but solved.

Can't get Ruby on Rails to work on Windows 7

This is a follow up to an earlier quesiton. I just installed Ruby on Rails using the rails installer (www.railsinstaller.org) but when I try to run any commants be it gem -v or rails new sample I get an error message saying:
Failed to load C:/Users/Zack/.gemrc due to permissions problem.
ANY ideas what to do would be very much appreciated. (Note that this is all being run on windows 7).
Was this just the only error you received in the console? Also have you checked if this file exists in the directory it is pointing to. if so what is in it. If you happen something like the following in the .gemrc you should have something like the following:
"gem": "--no-ri --no-rdoc"
This should work, providing this file exists. This can be caused when you installed Ruby using admin and then the file is created. For supported information check the following SO question this may also support you Ruby gem listed, but wont load
Probably there are two files .gemrc like in C:/Users/Zack/.gemrc and C:/ProgramData/gemrc/.gemrc. Verify and delete this last.

Rails could not find gem, found in bundle show

So if I try to start my server I get the error
Could not find abstract-1.0.0 in any of the sources
Try running bundle install.
I run that and I get
Using abstract (1.0.0)
Furthermore running a bundle show abstract gives me the correct path for the gem. That path is also referenced in gem env.
I'm really not sure how it can't be found...
You might have conflicting installations of ruby. One with the proper gem which you are using in the shell but one the server is using which doesn't have it installed properly.
I would check your environment variables to see if there is a conflict.
This can also happen if you are using RVM and have switched to a different version/gemset than the default one.
What command are you using to start the server?
If rails server is what is giving you the error, I recommend trying: bundle exec rails server
If that's not the issue, another question that might help troubleshoot; are you using rvm? What does rvm info give you?

Resources