I'm building an api only rails application that uses devise for user authentication. I'm following this guide and am on the step where I set up devise-jwt
, and when I run rake secret
I get the following:
rake aborted!
Don't know how to build task 'secret' (See the list of available tasks with `rake --tasks`)
When I look for available tasks, secret
is not one of them, but from what I can find on the internet, that's a task provided by rails out of the box.
Here's my Gemfile, if it's relevant (not including the gems that are commented out by default)
ruby "3.3.0"
gem "rails", "~> 7.1.2"
gem "sqlite3", "~> 1.4"
gem "puma", ">= 5.0"
gem "tzinfo-data", platforms: %i[ windows jruby ]
gem "bootsnap", require: false
gem "nokogiri"
gem "open-uri"
gem "devise"
gem "devise-jwt"
gem 'jsonapi-serializer'
group :development, :test do
gem "debug", platforms: %i[ mri windows ]
gem "pry-byebug"
end
group :development do
gem "annotate", git: 'https://github.com/ctran/annotate_models.git'
end
I do see that the secrets command is being deprecated in favor of credentials
, however that is not one of my tasks either. According to the rails documentation, the task should exist. What an I doing wrong? Was there a bad install of rails?
Troubleshooting:
$ rake secret
rake aborted!
Don't know how to build task 'secret' (See the list of available tasks with `rake --tasks`)
$ bundle exec rake -T | grep secret
(no output)
$ bundle exec rake -T
rake action_mailbox:ingress:exim # Relay an inbound email from Exim to Actio...
rake action_mailbox:ingress:postfix # Relay an inbound email from Postfix to Ac...
rake action_mailbox:ingress:qmail # Relay an inbound email from Qmail to Acti...
rake action_mailbox:install # Install Action Mailbox and its dependencies
rake action_mailbox:install:migrations # Copy migrations from action_mailbox to ap...
rake action_text:install # Copy over the migration, stylesheet, and ...
rake action_text:install:migrations # Copy migrations from action_text to appli...
rake active_storage:install # Copy over the migration needed to the app...
rake annotate_models # Add schema information (as comments) to m...
rake annotate_routes # Adds the route map to routes.rb
rake app:template # Apply the template supplied by LOCATION=(...
rake app:update # Update configs and some other initially g...
rake db:create # Create the database from DATABASE_URL or ...
rake db:drop # Drop the database from DATABASE_URL or co...
rake db:encryption:init # Generate a set of keys for configuring Ac...
rake db:environment:set # Set the environment value for the database
rake db:fixtures:load # Load fixtures into the current environmen...
rake db:migrate # Migrate the database (options: VERSION=x,...
rake db:migrate:down # Run the "down" for a given migration VERSION
rake db:migrate:redo # Roll back the database one migration and ...
rake db:migrate:status # Display status of migrations
rake db:migrate:up # Run the "up" for a given migration VERSION
rake db:prepare # Run setup if database does not exist, or ...
rake db:reset # Drop and recreate all databases from thei...
rake db:rollback # Roll the schema back to the previous vers...
rake db:schema:cache:clear # Clear a db/schema_cache.yml file
rake db:schema:cache:dump # Create a db/schema_cache.yml file
rake db:schema:dump # Create a database schema file (either db/...
rake db:schema:load # Load a database schema file (either db/sc...
rake db:seed # Load the seed data from db/seeds.rb
rake db:seed:replant # Truncate tables of each database for curr...
rake db:setup # Create all databases, load all schemas, a...
rake db:version # Retrieve the current schema version number
rake log:clear # Truncate all/specified *.log files in log...
rake remove_annotation # Remove schema information from model and ...
rake remove_routes # Removes the route map from routes.rb
rake stats # Report code statistics (KLOCs, etc) from ...
rake test # Run all tests in test folder except syste...
rake test:db # Reset the database and run `bin/rails test`
rake time:zones[country_or_offset] # List all time zones, list by two-letter c...
rake tmp:clear # Clear cache, socket and screenshot files ...
rake tmp:create # Create tmp directories for cache, sockets...
rake yarn:install # Install all JavaScript dependencies as sp...
rake zeitwerk:check # Check project structure for Zeitwerk comp...
Followed rails documentation
You should use bin/rails
for everything:
bin/rails secret
Since rails v5
you can run any rake
task via bin/rails
:
Proxy Rake tasks through bin/rails. (Pull Request, Pull Request)
https://guides.rubyonrails.org/5_0_release_notes.html#railties-notable-changes
secret
is a rails command, not a rake task, you can't run it through rake. You can list all rake tasks with:
bin/rails -T
# which is the same as
bin/rake -T
You can list all rails commands and rake tasks combined with:
bin/rails -h
Rails commands:
https://github.com/rails/rails/tree/v7.1.3/railties/lib/rails/commands
Rake tasks:
https://github.com/rails/rails/tree/v7.1.3/railties/lib/rails/tasks
(tasks can also be loaded from other gems)