cargo-dist: Bash installer is generated with CRLF linebreaks

As in title, the bash installer, for whatever reason, is generated with CRLF, which makes it effectively fail.

❯ cargo dist
analyzing workspace:
  portproxy
    [bin] portproxy

 WARN skipping powershell installer: not building any supported platforms (use --artifacts=global)
bundling portproxy-v0.2.0-aarch64-apple-darwin.tar.xz
bundling portproxy-v0.2.0-installer.sh
building cargo target (aarch64-apple-darwin/dist)
 (...)
bundled: /Users/mborejszo/source/portproxy/target/distrib/portproxy-v0.2.0-aarch64-apple-darwin.tar.xz
bundled: /Users/mborejszo/source/portproxy/target/distrib/portproxy-v0.2.0-installer.sh
announcing v0.2.0
  portproxy 0.2.0
    /Users/mborejszo/source/portproxy/target/distrib/portproxy-v0.2.0-installer.sh
    /Users/mborejszo/source/portproxy/target/distrib/portproxy-v0.2.0-aarch64-apple-darwin.tar.xz
      [bin] portproxy
      [misc] LICENSE.md, README.md
❯ file target/distrib/portproxy-v0.2.0-installer.sh
target/distrib/portproxy-v0.2.0-installer.sh: Bourne-Again shell script text executable, ASCII text, with CRLF, LF line terminators
❯ bash target/distrib/portproxy-v0.2.0-installer.sh
: command not foundproxy-v0.2.0-installer.sh: line 7:
: command not foundproxy-v0.2.0-installer.sh: line 14:
: invalid optionortproxy-v0.2.0-installer.sh: line 15: set: -
set: usage: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
: command not foundproxy-v0.2.0-installer.sh: line 16:
: command not foundproxy-v0.2.0-installer.sh: line 22:
'arget/distrib/portproxy-v0.2.0-installer.sh: line 23: syntax error near unexpected token `{
'arget/distrib/portproxy-v0.2.0-installer.sh: line 23: `download_binary_and_run_installer() {

Simple solution may be to run dos2unix conversion on the generated installer string.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (24 by maintainers)

Most upvoted comments

This is becoming more peculiar on hourly basis, huh! 😮

Yeah at this point I’d also vote for “better be sure” approach of #182, as I think no-one really knows why this happens (or does not happen).

i’ve opened a PR that i want to cut a release with to see if it works, if not, i’ll cut one with #182 - honestly i’m just very curious where the errant line endings are coming from at this point. feel like by the end of this i should write a blog post 😅

@milesj , @spitfire05 , thank you so much!! this is very helpful. i am still not 100% certain why i can’t reproduce but i think accepting #182 is the right call. given that i can’t reproduce, i’ll be taking ya’lls word for it that this fixes the issue (though it certainly would make sense to logically and was what @Gankra originally implemented in #148 before my (apparently foolish) git config suggestion) - i’m going to cut a 0.0.5-prerelease and will message here to ask if ya’ll could test it (assuming you are willing?)

Hmm interesting. I think it once generated a non-bugged installer when I was using a locally built cargo-dist from master branch, but I could not reproduce it later. Anyway, the simplest way I am reproducing this bug is:

❯ git clone https://github.com/axodotdev/cargo-dist.git
Cloning into 'cargo-dist'...
remote: Enumerating objects: 2037, done.
remote: Counting objects: 100% (633/633), done.
remote: Compressing objects: 100% (382/382), done.
remote: Total 2037 (delta 305), reused 437 (delta 234), pack-reused 1404
Receiving objects: 100% (2037/2037), 2.39 MiB | 8.06 MiB/s, done.
Resolving deltas: 100% (1062/1062), done.

~/source
❯ cd cargo-dist/

cargo-dist [ main][🦀 v1.67.1]
❯ cd cargo-dist/

cargo-dist/cargo-dist [ main][📦 v0.0.4][🦀 v1.67.1]
❯ cargo dist
analyzing workspace:
  cargo-dist
    [bin] cargo-dist
  cargo-dist-schema (no binaries)

 WARN skipping powershell installer: not building any supported platforms (use --artifacts=global)
bundling cargo-dist-v0.0.4-aarch64-apple-darwin.tar.xz
bundling cargo-dist-v0.0.4-installer.sh
building cargo target (aarch64-apple-darwin/dist)
   (...)
   Compiling cargo-dist v0.0.4 (/Users/mborejszo/source/cargo-dist/cargo-dist)
    Finished dist [optimized] target(s) in 24.61s
bundled: /Users/mborejszo/source/cargo-dist/target/distrib/cargo-dist-v0.0.4-aarch64-apple-darwin.tar.xz
bundled: /Users/mborejszo/source/cargo-dist/target/distrib/cargo-dist-v0.0.4-installer.sh
announcing v0.0.4
  cargo-dist 0.0.4
    /Users/mborejszo/source/cargo-dist/target/distrib/cargo-dist-v0.0.4-installer.sh
    /Users/mborejszo/source/cargo-dist/target/distrib/cargo-dist-v0.0.4-aarch64-apple-darwin.tar.xz
      [bin] cargo-dist
      [misc] CHANGELOG.md, LICENSE-APACHE, LICENSE-MIT, README.md

cargo-dist/cargo-dist [ main][📦 v0.0.4][🦀 v1.67.1][⏱ 27s]
❯ file ../target/distrib/cargo-dist-v0.0.4-installer.sh
../target/distrib/cargo-dist-v0.0.4-installer.sh: Bourne-Again shell script text executable, ASCII text, with CRLF, LF line terminators

bin version used (installed with cargo install):

❯ cargo dist --version
cargo-dist 0.0.4

I am currently on an M1 mac, will try to check on Windows tomorrow.

Hope that helps.