0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

git-bash から ruby を実行すると、引数として与えたファイルパスが変になる

Posted at

環境

  • Windows 10
  • ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x64-mingw32]
  • GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)

発生した問題

def upload(host, user, password, file, dest_path)
 p file
 p dest_path
...

thor を使って、こんな CLI アプリケーションを作成していたところ

$ bundle exec special_happy upload remote_host user password 'README.md' '/tmp/README.md'
"README.md"
"C:/Users/xxxx/AppData/Local/Temp/README.md"

二つ目のファイルパス ‘/tmp/README.md’ が置き換わってしまった。

解決方法

ruby - Git for Windowsに付属しているbashコンソールからrubyを実行すると指定した引数が書き換わる - スタック・オーバーフロー (stackoverflow.com)

原因は上記だった。 Git-bash が悪さをしていた。ファイルパスっぽいものを与えられると、よしなに解釈してしまうらしい。

コマンドプロンプト (cmd) にスイッチして、そちらで実行することで現象は解消された。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?