Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to bin/setup to make installation easier #3229

Merged
merged 7 commits into from
Nov 29, 2022
Merged

Conversation

briri
Copy link
Contributor

@briri briri commented Oct 27, 2022

Updated the ruby bin/setup script so that it:

  • Runs bundle install and yarn install
  • Creates the .env, config/database.yml and config/initializers/wicked_pdf.rb files
  • Opens vim to allow user to edit the information in the new .env file
  • Creates the initial config/credentials.yml.enc and master.key files and opens it for editing
  • Builds the DB
  • Populates the licenses, metadata_standards, and research_domains tables
  • Clears out any existing Rails cache
  • Provides instructions for populating the repositories table ... didn't include that one since it can take over 10 minutes

Will update the wiki installation page once this is merged into main in the next release.

Should address the issue outlined here: #3216

Copy link
Contributor

@benjaminfaure benjaminfaure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good :)

@johnpinto1
Copy link
Contributor

johnpinto1 commented Nov 8, 2022

@briri @benjaminfaure @pengyin-shan @martaribeiro Not sure why the setup fails for me. As always it must be something on my PC.

I am on an Ubuntu PC and I am using RVM to set the Ruby to version 2.7.2. Note I am using a newly cloned version of roadmap. I guess others are using their current. So don't see error as I won't have old recaptcha properties.
Failing as Credentials not available yet I am guessing. Checked and does not exist in config. See image below.

config.site_key = Rails.application.credentials.recaptcha[:site_key]

I have run the setup several times and it fails at db setup:

▶ ruby bin/setup

== Installing dependencies ==
The Gemfile's dependencies are satisfied

== Copying sample files ==

== Preparing database ==
/mnt/DataDrive1/DMP-WS/without-docker-roadmap/config/initializers/recaptcha.rb:8:in block in <main>': undefined method []' for nil:NilClass (NoMethodError)
from /home/jpinto/.rvm/gems/ruby-2.7.2/gems/recaptcha-5.12.3/lib/recaptcha.rb:37:in `configure'
from /mnt/DataDrive1/DMP-WS/without-docker-roadmap/config/initializers/reca
Selection_072

@briri
Copy link
Contributor Author

briri commented Nov 8, 2022

did the .env and credentials files ever open up in the editor for you @johnpinto1? If you look at the 2 new config/credentials.yaml.[db] files you'll see the recaptcha settings. It should be creating those files and opening them for you to edit.

I haven't used a PC though in over 15 years and don't a machine available to test with.

@johnpinto1 I just pushed a change that attempts to set the EDITOR env variable based on whether the platform is Windows. I suspect that it may fail though when it tries to seed the credentials file. Can you have a look and try it out?

If it doesn't work, can you use that Gem.win_platform? check and create versions of the following lines that will work for Windows? Feel free to make your changes to this branch (git fetch origin install-update && git checkout install-update)

  • Seed the credentials file with the correct sample based on the version of the DB the user specified: system! "EDITOR='echo \"$(cat config/credentials.yml.#{db_adapter})\" >' bin/rails credentials:edit"
  • Open the .env in an editor system! '$EDITOR .env' and wait for the user to save before continuing
  • Open the credentials in an editor system! 'bin/rails credentials:edit' and wait for the user to save before continuing

@johnpinto1
Copy link
Contributor

@briri That sorted issue of credentials. I just need to sort issue with duplicate tables after running db:migrate.
So I guess sorted. Thanks.

▶ rails db:migrate
Running via Spring preloader in process 3895
== 20131118094629 ChangeVersionsPublished: migrating ==========================
-- add_column(:versions, :published_tmp, :boolean, {})
-> 0.0014s
-- table_exists?("versions")
-> 0.0004s

@briri
Copy link
Contributor Author

briri commented Nov 8, 2022

excellent! You may need to delete the DB and start over from scratch. Sometimes a stalled installation can leave the DB in a state of limbo.
Try running bin/rails db:drop and then delete the entire installation directory, reclone and then start over

@johnpinto1
Copy link
Contributor

@briri I am testing the setup with Postgres. It is failing because the annotations table is never created in the migrations. Am I misunderstanding something. I don't see a migration file for creating this table.

Also with Postgres one has to run migrations twice at least because of the following error within a db:migrate because you can't change a type within a single transaction several times:

Caused by:

PG::FeatureNotSupported: ERROR: cached plan must not change result type

@briri
Copy link
Contributor Author

briri commented Nov 17, 2022

Thanks for trying it out @johnpinto1. I did some more reading on the new db:prepare and it looks like it runs: rails db:create && rails db:migrate && rails db:seed which is not what we want. I just switched it to use db:setup which runs rails db:create && rails db:schema:load && rails db:seed.

There are some very old migrations in the db/migrations/ directory that attempt to manipulate data using ActiveRecord models that no longer exist, so db:migrate is impossible to run from scratch.

@johnpinto1
Copy link
Contributor

@briri Phew that was the quickest fix. Yippee! up and running with Postgres using setup. Thanks.

@briri briri merged commit 57f1649 into development Nov 29, 2022
@briri briri deleted the install-update branch November 29, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants