LoginSignup
0
0

More than 5 years have passed since last update.

gitignore.ioのCLIコマンドで.gitignoreの内容がうまく生成できないときの対処法

Last updated at Posted at 2018-11-11

gitignore.ioとは

gitignoreをいい感じに生成してくれるWebサービスです。
コマンドラインからAPIを叩いて言語ごとにgitignoreを生成できたりします。便利ですね。

公式サイトに書いてあるインストール方法

Macでzshを使っている方の場合

以下のコマンドをターミナルで実行

echo "function gi() { curl -L -s https://www.gitignore.io/api/\$@ ;}" >> ~/.zshrc && source ~/.zshrc

上記のコマンドを実行後、gi node >> .gitignoreなどのコマンドを実行することでgitignoreを生成することができると書いてあるが動作しない

原因

curl -L -s https://www.gitignore.io/api/\$@ ;

curlの部分だけ

curl -L -s https://www.gitignore.io/api/node

こんな感じで試してみたが何も出ません。。。おそらくここでイカれてますね

取得先がhttpsから始まるURLなのでおそらくSSL関係でなにかコケてうまく取得できない状態になっているケースが多そうです。自分がそうでした。

対処法

コピペしたcurlのオプションの引数に-kをつける

-k… SSLのエラーを無視して処理を継続

先程のコマンドに-kを足してターミナルで実行してみましょう。

curl -L -s -k https://www.gitignore.io/api/node

結果(一部)

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# FuseBox cache
.fusebox/

# End of https://www.gitignore.io/api/node

上手く出たので動きました!

echo "function gi() { curl -L -s -k https://www.gitignore.io/api/\$@ ;}" >> ~/.zshrc && source ~/.zshrc

これで動くことが確認できました。

まとめ

gitignoreを秒で生成したかったので導入したのですがどこかでエラーが発生して詰まってしまいました。
動かすだけなら-kをつけるだけでいけそうですが、セキュリティ的な観点で言うとあまりベターな方法ではなさそうです。

あくまですぐ動かしたい!という方向けの記事ということをご理解ください。

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