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

Should use use path joining as the path separator, instead of hard-codes / . #71

Closed
golanguage opened this issue Nov 8, 2024 · 6 comments
Labels

Comments

@golanguage
Copy link

Link

Win10 system, build a project which depends on gpui,

after rustup overfide set nightly and rustup update to 1.84-nighgly
On pwsh 7.4.6, cargo build panic:

error: failed to run custom build command for `gpui v0.1.0 (C:\proj\rust\zed\crates\gpui)`
  cargo:rerun-if-changed=resources/windows/gpui.rc
  Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
  Copyright (C) Microsoft Corporation.  All rights reserved.

  fatal error RC1109: error creating \\?\C:\myproj\rust\gui\gpuimg\target\debug\build\gpui-a349b6bdb1d76471\out/gpui.lib

  --- stderr
  thread 'main' panicked at C:\rust\cargo\registry\src\rsproxy.cn-0dccff568467c15b\embed-resource-2.5.0\src\windows_msvc.rs:39:13:
  RC.EXE failed to compile specified resource file

A rust lang member said, it (embed-resource) does not use path joining and instead hard-codes / as the path separator, which is wrong for \?\ paths. here and here

On powershell 6 ,cargo is working correctly with 1.84 nightly.

@nabijaczleweli
Copy link
Owner

/ is still not a valid character in a filename, and it's a valid directory separator universally (except in this one specific edge-case on Win32), so cargo needs to apply the same fixup for all the paths it reads from cargo:rustc-link-arg-*= anyway to fix the entire extant corpus that does println!(cargo:rustc-link-arg-bins=$OUT_DIR/whatever) or ...=$(realpath .)/whatever.

As for building it here: yeah, sure, that's marginally a bug since we give it to other programs. Can you try the current master branch (at least 35a9ac6)?

nabijaczleweli added a commit that referenced this issue Nov 8, 2024
…to fix builds where $PWD is a \?\ path

Closes: #71
Backported-from: 35a9ac6
nabijaczleweli added a commit that referenced this issue Nov 8, 2024
…to fix builds where $PWD is a \?\ path

Closes: #71
Backported-from: 35a9ac6
@nabijaczleweli
Copy link
Owner

nabijaczleweli commented Nov 8, 2024

If the downstream you're building is still on embed-resource 2, test with v2.5-stable branch (at least af3fed9) please.

@golanguage
Copy link
Author

If the downstream you're building is still on embed-resource 2, test with v2.5-stable branch (at least af3fed9) please.

Thanks for your quick response.
But, I'm not a author of these crates. In fact, I'm a Rust newbie, try to learn GPUI, which seem use embeded-resource some where. I just forward other guy's comments, only understand a little about the bug.

@nabijaczleweli
Copy link
Owner

So, you should have something like

gpui = { git = "https://github.com/zed-industries/zed" }

in your Cargo.toml (and this fails to build for you) If you replace it with

gpui = { git = "https://github.com/nabijaczleweli/zed" }

then you'll use https://github.com/nabijaczleweli/zed with https://github.com/nabijaczleweli/zed/commit/c49760a6645d37a1c9d11f2525c2f46eb4a30a52 that will use the v2.5-stable branch off git. Can you try building this, and seeing if it fixes the build?

@golanguage
Copy link
Author

OK.
Now on pwsh 7.4.6 I get

...
...
   Compiling embed-resource v2.5.1 (https://github.com/nabijaczleweli/rust-embed-resource?branch=v2.5-stable#af3fed9a)
   Compiling imagesize v0.13.0
   Compiling roxmltree v0.20.0
   Compiling collections v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling derive_refineable v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling http_client v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling util v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling gpui v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling sum_tree v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling gpui_macros v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling usvg v0.44.0
   Compiling refineable v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling semantic_version v0.1.0 (https://github.com/nabijaczleweli/zed#c49760a6)
   Compiling resvg v0.44.0
   Compiling gpuimg v0.1.0 (C:\myproj\rust\gui\gpuimg)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 38s
     Running `target\debug\gpuimg.exe`
'''
Great!

@nabijaczleweli
Copy link
Owner

Cool, released in v3.0.1, backported as v2.5.1 and v1.6.14.

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