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

Adjust absolute paths on Windows for Docker #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

acornmakes
Copy link

The Windows Docker CLI has very specific requirements for absolute paths on Windows. The tool accepts absolute path formats such as /c/path/to/dest.

The Rust canonicalize function creates a UNC path which the Docker CLI command does not accept.

This PR addresses the issue #28 by adding a new function with a custom block of Windows only code (using cfg! macro) to reformat the path to a Docker CLI compatible path string. On other OSes, the string is returned as it was before, unchanged.

@rattling
Copy link

Tested this PR successfully.
I pulled this branch, created the exe on windows and it fixed the problem.
Thanks a mill!

@tylerxprice
Copy link

Built and tested locally on a Windows 10 host and rails-new was successful.

@diogocaetano
Copy link

Tested this PR successfully. I pulled this branch, created the exe on windows and it fixed the problem. Thanks a mill!

Hello. Can you explain how to create the exe for windows? I have the same issue.

@acornmakes
Copy link
Author

You'll need to install (at least temporarily) Rust. The compiler will need to be in the PATH before the next step.

Grab the source, and then from the root directory for the source, start a command prompt:

cargo build -r

That will download the used crates (packages) and creates the release build in \target\release\. You'll just need the rails-new.exe file.

You can uninstall Rust as it's not needed to run the exe.

@acornmakes acornmakes mentioned this pull request Nov 4, 2024
@diogocaetano
Copy link

You'll need to install (at least temporarily) Rust. The compiler will need to be in the PATH before the next step.

Grab the source, and then from the root directory for the source, start a command prompt:

cargo build -r

That will download the used crates (packages) and creates the release build in \target\release\. You'll just need the rails-new.exe file.

You can uninstall Rust as it's not needed to run the exe.

Thank you very much I will try

@diogocaetano
Copy link

diogocaetano commented Nov 6, 2024

@acornmakes Works! Thanks.

For those who need to do a build. You can get everything you need in a single command.

First download the code and go to the folder you installed it in, then run this Docker command.

docker run --rm --user "root":"root" -v "$PWD":/usr/src/myapp -w /usr/src/myapp rust:1.82-slim /bin/bash -c "apt update ; apt install mingw-w64 -y ; rustup target add x86_64-pc-windows-gnu ; cargo build --release --target x86_64-pc-windows-gnu"

This command uses the official Rust image in Docker, builds a volume with the current folder, installs the necessary libs to compile for Windows, and builds with the Windows target.

If you want to build for Linux, just use the command

docker run --rm --user "root":"root" -v "$PWD":/usr/src/myapp -w /usr/src/myapp rust:1.82-slim cargo build --release

The build file will be in \target\release\

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

Successfully merging this pull request may close these issues.

4 participants