Reputation: 1343
Running simple command
rails g model User
leads to:
→ bundle exec rails g model User
invoke active_record
create db/migrate/20160128191020_create_users.rb
create app/models/user.rb
invoke rspec
create spec/models/user_spec.rb
invoke factory_girl
create /spec/factories/users.rb
/Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:252:in `mkdir': Permission denied @ dir_s_mkdir - /spec (Errno::EACCES)
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:252:in `fu_mkdir'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:226:in `block (2 levels) in mkdir_p'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:224:in `reverse_each'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:224:in `block in mkdir_p'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:210:in `each'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/2.2.0/fileutils.rb:210:in `mkdir_p'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:61:in `block in invoke!'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `call'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/factory_girl_rails-4.5.0/lib/generators/factory_girl/model/model_generator.rb:46:in `create_factory_file'
from /Users/khataev/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/factory_girl_rails-4.5.0/lib/generators/factory_girl/model/model_generator.rb:25:in `create_fixture_file'
rest is omitted.
I'm using factory girls rails. spec
and spec/factories folders
' permissions are drwxr-xr-x (755, change to 777 had no effect). Re installation of factory_girl_rails
had no effect. Ruby 2.2.2
(tried different versions already)
Upvotes: 0
Views: 3547
Reputation: 4217
You need to grant permissions to access the required directory for the system root user
sudo chmod 777 -R your_project_directory_to_be_access
In your case you can use:
sudo chmod 777 -R /spec/
For security reasons, just keep in your mind:
chmod 777
gives everybody read, write and execute rights which for most problems is definitively too much.
Upvotes: 1
Reputation: 2598
Maybe you did:
# config/application.rb
config.generators do |g|
g.fixture_replacement :factory_girl, dir: "/spec/factories"
end
If so, you need to change it from "/spec/factories" to "spec/factories"
Reference: https://github.com/everydayrails/rails-4-1-rspec-3-0/blob/master/config/application.rb
Upvotes: 1