I accidentally created a Rails app in my root directory. I ran the following command and got an error:
rails new test_app
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
So I tried running
bundle exec rails server
and it looks like the server is listening on port 3000.
How do I remove this app from my root directory?
Just delete the folder or you can execute this command
rm -rf test_app
Hoping you're on *nix based system.
Stop the running server using:
kill -9 $(lsof -t -i :3000)
Change working directory to root using:
cd /
or wherever you're defining your root as.
Remove the accidentally created Rails application directory using:
rm -fr rails_project_in_root_dir
where rails_project_in_root_dir is the Rails application directory in your root directory.
Okay, I'm not sure how it got installed in the root directory, but I ended up just manually deleting all the folders and files that get created when you run
rails new app
Here's where I found the list of files:
http://guides.rubyonrails.org/getting_started.html
That ended up resolving the issue. Thanks for the help guys.
Related
I'm trying to generate a migration for my Rails 4 project running within Docker.
What I've tried so far is
docker-compose run web rails g migration migration_name
docker-compose exec web rails g migration migration_name
Terminal keeps saying me that everything is ok, the migration was successfully created and all. But i don't see migration file in my project.
However if I check the project files in Docker
docker-compose exec web bash
ls -l db/migrate/
I see that the file is actually there.
I'm on Mac OS X if it could help
You should look into making your root app directory a volume on your host machine. Documentation on volumes.
In your docker-compose.yml, you can add your root volume using:
volumes:
- .:/YOUR-APP-NAME
When mounting properly it still took a minute or two to show up in my IDE
When running rails generate on a new Rails 4.2 project, I keep getting the error:
~/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.0/lib/spring/configuration.rb:37:in `pwd': No such file or directory - getcwd (Errno::ENOENT)
How can I fix this?
The error is caused by an existing Rails Spring process running in the background.
You can easily solve this by running ps ax | grep spring to find the process id and then kill it.
There's an issue on the Rails GitHub about this:
https://github.com/rails/spring/issues/247
This error may also occur if you are working in a directory which was deleted from some other terminal instance.
If the directory (or some sub directory Rails will work with) you are working was renamed or removed, you'll have to run
cd .
and then you can run rails generate [...].
On my machine the same problem was arising because spring server stopped responding.
1:- To restart the spring server type in terminal
$: spring restart
2:- Try running the generator again.
I'm getting this error:
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first
But I'm not in a rails directory, I'm on the desktop. There's no .bundle files anywhere to be found. Any ideas?
cd bin/
rm -rf rails
This fixed my problem. I was also getting the same error message
"Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Type 'rails' for help."
I was struggling with this over the weekend, but after lots of prodding and poking got it to work.
The problem for me was that Aptana (I believe) created a second rails script in my local bin directory (~/bin) which was called instead of the system script. This local version was older than /usr/local/bin/rails. After moving aside ~/bin/rails, "rails new fred" worked as expected.
Try creating a new folder or rails app in root folder, under ~/
I was having the same problem this morning and that's because rails was already been there while i was creating my application.
To remove the error just go to bin folder of your application and remove the rails folder, and try to create new rails application in your planned folder using rails new app_name.
When I run a rails app and navigate with browser to them I get an error from rails:
Permission denied - /path/to/my_rails_app/tmp/cache/assets/development/sprockets/37b5a12047376b10a57191a10d3af30a rails error
And I have no such file/folders behind the ./tmp/. What is the problem?
I experienced this same issue.
Permission denied # apply2files
The problem is that tmp directory in your application directory is not writable to the current user, that is, the current user does not have permission to write to the tmp directory in your application directory.
Here's how I solved it:
Simply delete the tmp directory in your application directory with superuser rights:
sudo rm -rf tmp
Do not recreate the tmp directory again, it's a waste of effort
Simply start your application and the tmp directory will be created automatically again:
rails s
That's all.
I hope this helps
The user who created or 'owns" the my_rails_app directory isn't writable by the server.
chown -R webserveruser:webserveruser /path/to/my_rails_app
Change the webserveruser to http, or apache or whatever username is running your server. The entitiy to the right of the : is the group, use a group name that is writable by your user if you need write access without changing users.
The reason this error was happening for me was because I was running
ruby bin/rails server
instead of
ruby bin/rails server -e development
try this:
rm -rf public/assets
rake assets:clean RAILS_ENV=development
chown -R nginx:nginx /www/rblpt/
I'm using carrierwave in a rails app to upload files. It works fine on my development environment, but on my production VM (Ubuntu), I'm getting this error:
An Errno::EACCES occurred in users#update:
Permission denied - /home/yards/apps/yardsapp/releases/20130616143623/public/uploads/tmp/20130616-1438-14186-3184
/usr/local/lib/ruby/1.9.1/fileutils.rb:244:in `mkdir'
I'm pretty sure I understand what is going on, but I can't seem to figure out a fix. My capistrano deploy.rb is set up with the user as root. So when it creates the new release folder on a deploy, the access rights are for root (I think).
Then when I try to upload a file, I get that error because nginx is trying to execute a mkdir as www-data.
I could chown the folder after the deploy and it works...but then another deploy creates another new directory with owner set to root as default.
At least I think this is what is going on. Does anyone have any ideas on how I should be doing this?
Run your deployment as www-data. You might need to adjust the authorized_keys file for the www-data user as well to be able to connect.
To fastest way would be to copy over your authorized_keys file for whatever user you are using at the moment (assuming you are root):
mkdir $WWW_DATA_HOME/.ssh
cp ~/.ssh/authorized_keys $WWW_DATA_HOME/.ssh/authorized_keys
chown www-data:www-data $WWW_DATA_HOME/.ssh/authorized_keys
You might also need to change the shell for the www-data user to log in to it:
chsh -s /bin/bash www-data
Now you should be able to do
ssh www-data#your-host.tld
and log in.
What this came down to was an improper Capistrano configuration. I followed the capistrano docs correctly (and made a 'deployer' user, same thing as the www-data as suggested above) and I have capistrano working like a charm. Also upgraded to Capistrano 3.