コレグレーデギネード

WindowsとかUbuntuとかRubyとかRailsとか

PosgreSQLのデータベースのバックアップとリストア

デフォルトのバックアップコマンド pg_dump
・デフォルトのスクリプト形式を選択するとpsqlコマンドでリストアできる。

$ pg_dump database名 > backup_file名

リストアコマンド psql

$ psql database名 < backup_file名

アーカイブ形式のリストアコマンド pg_dump
アーカイブ形式の場合はpg_dumpに-Fオプションをつける

$ pg_dump -Fc database名 > backup_file名

・-cはcustom形式を表す。-tとするとtar形式になる
リストアコマンド pg_restore

$ pg_restore -d database名 backup_file名

参考:PostgreSQLのbackup, restore方法まとめ #PostgreSQL - Qiita

rake aborted! 01 Sprockets::FileNotFound: couldn't find file 'trix/dist/trix' with type 'text/css'

app/assets/stylesheets/actiontext.scss
//=-require trix/dist/trixの行を削除

//
// Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
// the trix-editor content (whether displayed or under editing). Feel free to incorporate this
// inclusion directly in any other asset bundle and remove this file.
//
- //=-require trix/dist/trix
//
// We need to override trix.css’s image gallery styles to accommodate the
// <action-text-attachment> element we wrap around attachments. Otherwise,
// images in galleries will be squished by the max-width: 33%; rule.

参考:【解決方法】couldn't find file 'trix/dist/trix' with type 'text/css" とは? #Rails - Qiita

Since uri is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports uri as a default gem. (Gem::LoadError)

Ubuntu 20.04だとエラーにならないのに22.04だとエラーが出てdeployできない。

rake stdout: Nothing written
rake stderr: bundler: failed to load command: rake (/var/www/rails/shared/bundle/ruby/2.7.0/bin/rake)
/usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/runtime.rb:304:in `check_for_activated_spec!': You have already activated uri 0.10.0, but your Gemfile requires uri 0.13.0. Since uri is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports uri as a default gem. (Gem::LoadError)
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/runtime.rb:25:in `block in setup'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/spec_set.rb:165:in `each'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/spec_set.rb:165:in `each'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/runtime.rb:24:in `map'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/runtime.rb:24:in `setup'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler.rb:162:in `setup'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/setup.rb:23:in `block in <top (required)>'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/ui/shell.rb:159:in `with_level'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/ui/shell.rb:111:in `silence'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/setup.rb:23:in `<top (required)>'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/cli/exec.rb:56:in `require_relative'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/cli/exec.rb:56:in `kernel_load'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/cli/exec.rb:23:in `run'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/cli.rb:492:in `exec'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/cli.rb:34:in `dispatch'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/cli.rb:28:in `start'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/exe/bundle:37:in `block in <top (required)>'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /usr/local/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-2.4.18/exe/bundle:29:in `<top (required)>'
	from /usr/local/rbenv/versions/2.7.1/bin/bundle:23:in `load'
	from /usr/local/rbenv/versions/2.7.1/bin/bundle:23:in `<main>'
	1: from /home/user/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.22.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/home/user/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.22.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as user@hostname: rake exit status: 1 (SSHKit::Runner::ExecuteError)


Ubuntu 22.04 Serverの場合は(サーバー側の)gem uriのバージョンを0.13.0にする

サーバーのgemをチェック

$ gem list
 :
uri 0.10.0
 :

uriをバージョン指定してupdateする

$ sudo gem install uri -v 0.13.0

これでOK

Deployの際に01 ERROR in ./app/javascript/packs/application.js 01 Module build failed (from ./node_modules/babel-loader/lib/index.js): 01 Error: Cannot find package '@babel/plugin-proposal-private-methods' imported from

package.jsonとbabel.config.jsの下記proposalの部分をtransformに書き換え

- @babel/plugin-proposal-private-methods
+ @babel/plugin-transform-private-methods
- @babel/plugin-proposal-private-property-in-object
+ @babel/plugin-transform-private-property-in-object