Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparently, the --skip-postinstall option is broken on Linux, Mac, and Windows. #498

Open
straight-shoota opened this issue Apr 24, 2021 · 4 comments
Labels

Comments

@straight-shoota
Copy link
Member

Apparently, the option is broken on Linux, Mac, and Windows.

From crystal-ameba/ameba#230 (comment) :

  • Ubuntu:
Run shards install --ignore-crystal-version --skip-postinstall
  shards install --ignore-crystal-version --skip-postinstall
  shell: /usr/bin/bash -e {0}
Resolving dependencies
Fetching https://github.com/stumpycr/stumpy_png.git
Fetching https://github.com/stumpycr/stumpy_bmp.git
Fetching https://github.com/crystal-ameba/ameba.git
Fetching https://gitlab.com/arctic-fox/spectator.git
Fetching https://github.com/askn/faker.git
Fetching https://github.com/crystal-community/hardware.git
Fetching https://github.com/stumpycr/stumpy_core.git
Installing stumpy_core (1.9.1)
Installing stumpy_png (5.0.1)
Installing stumpy_bmp (0.2.0)
Installing ameba (0.14.3)
Unhandled exception: Error opening file with mode 'r': '/home/runner/work/crystal_ray_tracer/crystal_ray_tracer/lib/ameba/bin/ameba': No such file or directory (File::NotFoundError)
Postinstall of ameba: make bin && make run_file (skipped)
  from /crystal/src/crystal/system/file.cr:7:7 in 'new'
  from /crystal/src/file.cr:627:12 in 'install_executables'
  from /shards/src/commands/install.cr:78:11 in 'run:ignore_crystal_version'
  from /shards/src/cli.cr:100:9 in '->'
  from /crystal/src/primitives.cr:255:3 in 'parse'
  from /shards/src/cli.cr:145:3 in '__crystal_main'
  from /crystal/src/crystal/main.cr:110:5 in 'main'
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'
Error: Process completed with exit code 1.
  • MacOS:
Run shards install --ignore-crystal-version --skip-postinstall
Resolving dependencies
Fetching https://github.com/stumpycr/stumpy_png.git
Fetching https://github.com/stumpycr/stumpy_bmp.git
Fetching https://github.com/crystal-ameba/ameba.git
Fetching https://gitlab.com/arctic-fox/spectator.git
Fetching https://github.com/askn/faker.git
Fetching https://github.com/crystal-community/hardware.git
Fetching https://github.com/stumpycr/stumpy_core.git
Installing stumpy_core (1.9.1)
Installing stumpy_png (5.0.1)
Installing stumpy_bmp (0.2.0)
Installing ameba (0.14.3)
Unhandled exception: Error opening file with mode 'r': '/Users/runner/work/crystal_ray_tracer/crystal_ray_tracer/lib/ameba/bin/ameba': No such file or directory (File::NotFoundError)
Postinstall of ameba: make bin && make run_file (skipped)
  from raise<File::Error+>:NoReturn
  from File::new<String, String, File::Permissions, Nil, Nil>:File
  from Shards::Package#install_executables:Nil
  from Shards::Commands::Install@Shards::Command::run:ignore_crystal_version<String, Bool>:(Array(Log::Entry) | Channel(Tuple(Log::Entry, Log::Backend+)) | IO+ | Nil)
  from ~procProc(Array(String), Array(String), Nil)@src/cli.cr:52
  from OptionParser#parse<Array(String)>:Nil
  from __crystal_main
  from main
Error: Process completed with exit code 1.
  • Windows:
Run shards install --ignore-crystal-version --skip-postinstall
Resolving dependencies
Fetching https://github.com/stumpycr/stumpy_png.git
Fetching https://github.com/stumpycr/stumpy_bmp.git
Fetching https://github.com/crystal-ameba/ameba.git
Fetching https://gitlab.com/arctic-fox/spectator.git
Fetching https://github.com/askn/faker.git
Fetching https://github.com/crystal-community/hardware.git
Fetching https://github.com/stumpycr/stumpy_core.git
Installing stumpy_core (1.9.1)
Installing stumpy_png (5.0.1)
Installing stumpy_bmp (0.2.0)
Installing ameba (0.14.3)
Postinstall of ameba: make bin && make run_file (skipped)
Unhandled exception: Error opening file with mode 'r': 'D:\\a\\crystal_ray_tracer\\crystal_ray_tracer\\lib\\ameba\\bin\\ameba.exe': No such file or directory (File::NotFoundError)
Error: Process completed with exit code 1.

Originally posted by @drhuffman12 in #468 (comment)

@straight-shoota
Copy link
Member Author

@straight-shoota says: Oh, that looks like a shards bug. --skip-postinstall should probably skip installing executables, too.
Ref: crystal-ameba/ameba#230 (comment)

I think the should warn if the source file does not exist.
If is used it will warn, which would be expected.
But there could be other reasons why that file is missing (like author's error) and warning about it should be enough I think.

I think it would be weird to skip the install executable entirely if is used.

WDYT?

Originally posted by @bcardiff in #468 (comment)

@straight-shoota
Copy link
Member Author

straight-shoota commented Apr 24, 2021

My opinion is that installing executables is a postinstall action. And as such I'd expect it to be affected by --skip-postinstall.

Without that flag, a missing (or unreadable) file would be an error. To avoid that error, you can use the --skip-postinstall flag.

There is a strong correlation between scripts.postinstall and executables, so tying both with the same skip flag seems very reasonable. Some stats: In the shardbox database, 11 shards have executables defined. Eight of them build the executable via postinstall script. One doesn't do postinstall but ships the built executable in the repo (which doesn't seem like a great solution). Two define executables that don't exist, installing them as dependencies fails. And I think that's correct. The error message should be improved, though.

@bcardiff
Copy link
Member

To me the fact that installing executables is done after a postinstall does not imply that is part of it. If it would, then it should be inside the postinstall: in the shard.yml. But is only a preference. I think warning would be more clear and enough so we don't tight up two features together that to me are independent.

@straight-shoota
Copy link
Member Author

I don't mean to imply executable installation to be part of the postinstall scripts. But it also happens after installation, so it's also "postinstall" (although different). And the flag is --skip-postinstall. It's not --skip-postinstall-scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants