The file '/usr/local/bin/bundle' is marked as an executable but could not be run by the operating system.
最近は仕事では Docker 上で開発することがほとんどでローカルでRubyをいじらない。 いつからか ローカルでの bundle install が失敗するようになっていた。 bashのshebangを実行ファイルに書くと良いという情報があったが、それでもなおらなかった。
$ bundle install Failed to execute process '/usr/local/bin/bundle'. Reason: exec: Exec format error The file '/usr/local/bin/bundle' is marked as an executable but could not be run by the operating system.
とりあえずbundlerを入れ直そうと思い、削除したところなおった。
$ rm /usr/local/bin/bundler /usr/local/bin/bundle
削除後、以下のパスの bundler が使われるようになった。
$ /Users/suzuki_y/.rbenv/shims/bundle
/usr/local/bin/bundler のソースコードには、コメントで「この bundler は gem インストール時に作成したもの」と書かれていたので、 rubygems側で作ったbundlerを誤って使うようになっていたのかもしれない。