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

Unable to create a working environment. #23

Closed
Jezza opened this issue Oct 29, 2021 · 20 comments
Closed

Unable to create a working environment. #23

Jezza opened this issue Oct 29, 2021 · 20 comments

Comments

@Jezza
Copy link

Jezza commented Oct 29, 2021

This might link to esp-rs/rust-build#8, as I haven't installed ESP-IDF yet.
But I'm unable to compile libsodium.

image

@MabezDev
Copy link
Member

What version of esp-idf-sys are you using? I believe there was an issue in an older release building libsodium.

@MabezDev MabezDev transferred this issue from esp-rs/rust-build Oct 29, 2021
@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

Just the one that rust-esp32-std-demo uses: 0.21.1

https://github.com/ivmarkov/rust-esp32-std-demo/blob/main/Cargo.toml#L58:

esp-idf-sys = { version = "0.21.1", features = ["binstart"] }

There does seem to be a newer one out.
I'll switch to that, and see if that works.
If so, I'll make a PR for it.

@MabezDev
Copy link
Member

If you are on windows, this could also be a long file path issue. Maybe try out the native feature of esp-idf-sys if the new version one.

@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

It seems that esp-idf-svc and friends are all on 0.21.
I'll try out the native feature, and see how that goes.

And failing that, I'll patch the libraries, and bump the version for all of them.

@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

Seems I can't build esp-idf-sys with the native, as it fails with unable to find Ninja.
Patching it, and telling it to find ninja, just results in some weird output.

native feature:
image

patched version: (So it's looking for ninja)
image

@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

I'll go install ninja, and see if it works with that.

@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

Ninja is installed, and working.
Seems that it's looking for xtensa-esp32-elf-gcc.

image

@N3xed
Copy link
Collaborator

N3xed commented Oct 29, 2021

This really shouldn't happen, cmake is somehow not getting the correct PATH set (both gcc and ninja are automatically installed by the build script).

You could try printing the PATH variable inside the CMakeLists.txt file, by adding the line message(STATUS "$ENV{PATH}") to the beginning of it. Add the line to the CMakeLists.txt inside the out dir of esp-idf-sys and try recompiling with cargo build -vv.

One issue that could cause this is if you have cygpath in your PATH. Try running cygpath if it works and your not inside git-bash or the likes, this would probably cause issues. Also try compiling your project with git-bash itself.

@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

Ok, after some troubleshooting, it's definitely because I have cygpath on my PATH.

The problematic code is in embuild.
By the looks of it, cygwin (or more specifically, git-bash), does set some env variables that could be looked at, just to make sure the tty is, in fact, from cygwin.

However, that's not all.
That, unfortunately, leads me straight into another issue.
Whether I patch embuild or if I run it directly from mingw64, the issue is the same:

image

image

I'm going to assume the -I args are wrong, so I'll start looking through them.

@Jezza
Copy link
Author

Jezza commented Oct 29, 2021

Weird.
Maybe a symlink was supposed to be generated.

image

I've found the files, but the includes are pointing to a completely different location.

@N3xed
Copy link
Collaborator

N3xed commented Oct 30, 2021

I think you're running into windows path length limitations: see Microsoft docs.

@N3xed
Copy link
Collaborator

N3xed commented Oct 30, 2021

Ok, after some troubleshooting, it's definitely because I have cygpath on my PATH.

The problematic code is in embuild. By the looks of it, cygwin (or more specifically, git-bash), does set some env variables that could be looked at, just to make sure the tty is, in fact, from cygwin.

I've created a new release that should fix this issue. I guess the first workaround that I implemented to circumvent issues with msys or cygwin on Windows was not that great, but these problems should be fixed now.

@Jezza
Copy link
Author

Jezza commented Oct 30, 2021

Weird, even after setting the long paths flag, I'm still getting the same error.

I played around with it a bit and got a new error:
image

I'm a bit lost with this one though...

@N3xed
Copy link
Collaborator

N3xed commented Oct 30, 2021

I played around with it a bit and got a new error: image

I'm a bit lost with this one though...

This error is unrelated, I'm not sure how it happens but I fixed it by just copying the other binaries (like cargo,
cargo-clippy, cargo-fmt, clippy-driver and rustfmt) from the nightly toolchain to the esp toolchain. I think it has to do with cargo concurrently linking to these executables (the nightly ones are used if the used toolchain doesn't have them).

Note: You have to copy the .dlls too (.pdbs should only be needed for debugging purposes, but why not copy them too).

We should really open an issue for this one upstream, and for the temporary fix in rust-build (maybe).

@georgik
Copy link

georgik commented Nov 1, 2021

@Jezza The first error is caused by too long build path. Move the project to shorter path. This is known limitation of Windows build via Platform IO. It's quite misleading that it fails on libsodium. The libsodium is the first library which has files on very long paths, so the build fails there.

@Jezza
Copy link
Author

Jezza commented Nov 1, 2021

@georgik I'm not building it with Platform IO anymore, I switched to native.
I also ended up enabling long paths in windows.

The current issue I'm facing is still being unable to find headers:
this one

@georgik
Copy link

georgik commented Nov 1, 2021

Just FYI @Jezza Long Paths on Windows does not solve the problem. For some unknown reason this setting is ignored during the build.

@Jezza
Copy link
Author

Jezza commented Nov 1, 2021

Ah, I see.
Nice to know.

@N3xed
Copy link
Collaborator

N3xed commented Nov 1, 2021

With a little bit of research this seems to be a gcc limitation.

Possible workarounds:

  • Use subst to assign a virtual drive letter to a path (should work as pointed out here).
  • Create a directory junction (with mklink /j) to shorten the path (not tested).
  • Moving the project to a directory with a shorter path.

If this is a common issue, it may be worth trying to implement a workaround (for example forcing cmake to use relative paths, creating directory junctions ourselves, etc.).

@MabezDev
Copy link
Member

Closing due to inactivity, I hope that by now all the issues are resolved. Please file another if this is not the case.

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

No branches or pull requests

4 participants