libreadlineのエラーでrails consoleが動かない問題
解決法
とりあえず解決した方法。
無いぞと言われてるパスにシンボリックリンクを張る
ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
出たエラー
/Users/user/.rbenv/versions/2.4.0/lib/ruby/2.4.0/irb/completion.rb:10:in `require': dlopen(/Users/user/.rbenv/versions/2.4.0/lib/ruby/2.4.0/x86_64-darwin16/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError) Referenced from: /Users/user/.rbenv/versions/2.4.0/lib/ruby/2.4.0/x86_64-darwin16/readline.bundle Reason: image not found - /Users/user/.rbenv/versions/2.4.0/lib/ruby/2.4.0/x86_64-darwin16/readline.bundle from /Users/akinov/.rbenv/versions/2.4.0/lib/ruby/2.4.0/irb/completion.rb:10:in `<top (required)>' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:2:in `require' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:2:in `<top (required)>' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/behavior.rb:82:in `require' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/behavior.rb:82:in `block (2 levels) in lookup' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/behavior.rb:78:in `each' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/behavior.rb:78:in `block in lookup' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/behavior.rb:77:in `each' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command/behavior.rb:77:in `lookup' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:68:in `find_by_namespace' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:42:in `invoke' from /Users/akinov/work/rails_project/test/example/vendor/bundle/ruby/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>'
その他、試した方法
StackOverflowでbrewで再インストールしろよって回答があったがこちらはダメだった
brew rm -f readline brew install readline brew link readline --force
macOSをHighSerriaにアップグレードしたらVagrantやVirtualBoxが動かなくなった
解決法
システム環境設定
-> セキュリティとプライバシー
-> いくつかのシステムソフトウェアの読み込みがブロックされました
-> 許可
Oracle America inc
にチェック
状況
vagrant up
したら何やら怒られた
vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'bento/ubuntu-14.04' is up to date... ==> default: A newer version of the box 'bento/ubuntu-14.04' is available! You currently ==> default: have version '2.2.7'. The latest is version '201708.22.0'. Run ==> default: `vagrant box update` to update. ==> default: Clearing any previously set network interfaces... There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below. Command: ["hostonlyif", "create"] Stderr: 0%... Progress state: NS_ERROR_FAILURE VBoxManage: error: Failed to create the host-only adapter VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 71 of file VBoxManageHostonly.cpp
vagrant失敗する場合VirtualBoxを再インストールしたらいいとの記事を見つけて再インストールしてみた
brew cask install virtualbox ==> Satisfying dependencies ==> Downloading http://download.virtualbox.org/virtualbox/5.1.26/VirtualBox-5.1.26-117224-OSX.dmg ######################################################################## 100.0% ==> Verifying checksum for Cask virtualbox ==> Installing Cask virtualbox ==> Running installer for virtualbox; your password may be necessary. ==> Package installers may write to any location; options such as --appdir are ignored. Password: ==> installer: Package name is Oracle VM VirtualBox ==> installer: Installing at base path / ==> installer: The install failed (エラーによってインストールできませんでした。ソフトウェアの製造元に問い合わせてください。) Error: Command failed to execute! ==> Failed command: /usr/bin/sudo -E -- /usr/sbin/installer -pkg /usr/local/Caskroom/virtualbox/5.1.26-117224/VirtualBox.pkg -target / ==> Standard Output of failed command: installer: Package name is Oracle VM VirtualBox installer: Installing at base path / installer: The install failed (エラーによってインストールできませんでした。ソフトウェアの製造元に問い合わせてください。) ==> Standard Error of failed command: ==> Exit status of failed command: #<Process::Status: pid 8033 exit 1> Error: Install incomplete.
失敗
改めて解決法
環境設定でロックされているだけでした。
システム環境設定
-> セキュリティとプライバシー
-> いくつかのシステムソフトウェアの読み込みがブロックされました
-> 許可
Oracle America inc
にチェック
エラーは分かりやすくして欲しい…
Rails RansackでNULLS LASTでsortする
Ransackのconditionには入れられないらしい
NULLS LASTでsortするには Ransackの外側で普通にOrder指定する
Model.search(conditions).result.order('column DESC NULLS LAST')
脱Ransackしたい
参考
How to add NULL LAST to sorts · Issue #443 · activerecord-hackery/ransack · GitHub
RailsでPostgreSQLにNULLS LASTのインデックスを追加する方法
タイトルママ
nulls lastのインデックスを作りたいけどなかなか見つからなかったので書きました。
migration にこれ
add_index :table, :column, order: { column: 'DESC NULLS LAST' }
参考
PostgreSQL: Ordering, NULLs, and indexes - makandropedia
元のPostgreSQLのオプションはこちらで確認できます
https://www.postgresql.jp/document/8.3/html/sql-createindex.html
Reactで Uncaught TypeError: Cannot read property 'setState' of undefined と怒られた時の対処方
コンストラクタで明示的にthisをbindして上げる必要があるらしい
constructor(props) { super(props); this.onChangeValue = this.onChangeValue.bind(this); }
参考
ES6でReact使ってたらsetStateがundefinedとか怒られた件 - とっしぃのTech Memo
Reactで Uncaught TypeError: Cannot read property 'setState' of undefined と怒られる場合の対処法 - Qiita