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

Improve error message when there's a colon in the project directory name #3736

Closed
minijackson opened this issue Feb 20, 2017 · 15 comments · Fixed by #11318
Closed

Improve error message when there's a colon in the project directory name #3736

minijackson opened this issue Feb 20, 2017 · 15 comments · Fixed by #11318
Assignees
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug Command-init Command-new E-easy Experience: Easy

Comments

@minijackson
Copy link

minijackson commented Feb 20, 2017

Steps to reproduce:

  • cargo new bla
  • mv bla "bla:"
  • cd "bla:"
  • cargo test --verbose

Error:

error: failed to join search paths together: path segment contains separator `:`
Does $LD_LIBRARY_PATH have an unterminated quote character?

Caused by:
  failed to join path array: ["/tmp/bla:/target/debug/deps", "/home/minijackson/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"]

As LD_LIBRARY_PATH is a Unix thingy, I don't know if it is reproducible in Windows ;-)

Meta:

cargo 0.18.0-nightly (56083a3 2017-02-18)
release: 0.18.0
commit-hash: 56083a3362999695193a8f2252d17b0e4c32145e
commit-date: 2017-02-18
@alexcrichton
Copy link
Member

IIRC a colon is an illegal character in a path on Windows, but we probably shouldn't fail like this on Unix.

@cyplo
Copy link

cyplo commented Aug 6, 2017

Would it be worth promoting this issue as beginner-friendly ?

@alexcrichton
Copy link
Member

Ah no unfortunately I don't think this'll be easy to fix, all we can really do is probably provide a better error message :(

@carols10cents carols10cents added A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug labels Oct 2, 2017
@carols10cents carols10cents changed the title Allow colons in project directory name Improve error message when there's a colon in the project directory name Oct 2, 2017
@stale
Copy link

stale bot commented Sep 20, 2018

As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it.

I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect?

The team would be especially grateful if such a comment included details such as:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you for contributing!

(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

@stale stale bot added the stale label Sep 20, 2018
@stale
Copy link

stale bot commented Oct 20, 2018

As I didn't see any updates in 30 days I'm going to close this. Please see the previous comment for more information!

@stale stale bot closed this as completed Oct 20, 2018
@grunweg
Copy link

grunweg commented Mar 7, 2021

I just ran into this issue:
while a search for "path segment contains separator" found this issue quickly, being told about the cause (colons in the directory name) would have made this easier.

@ehuss
Copy link
Contributor

ehuss commented Mar 8, 2021

I can reopen, adding a better error message probably shouldn't be too difficult.

@ehuss ehuss reopened this Mar 8, 2021
@ehuss ehuss removed the stale label Mar 8, 2021
@mcepl
Copy link

mcepl commented Aug 3, 2021

This is a massive problem for me while building openSUSE packages, because our project names always include a colon. See building of python-maturin package:

maturin-0.11.2@kusansky$ env|grep LIB
PERL5LIB=/home/matej/.local/share/perl5
LIBVIRT_DEFAULT_URI=qemu:///system
RUBYLIB=/home/matej/.gem/local
maturin-0.11.2@kusansky$ pwd
/home/matej/build/devel:languages:python/python-maturin/maturin-0.11.2
maturin-0.11.2@kusansky$ cargo build
error: failed to join search paths together
Does $LD_LIBRARY_PATH have an unterminated quote character?

Caused by:
  failed to join path array: ["/home/matej/build/devel:languages:python/python-maturin/maturin-0.11.2/target/debug/deps", "/usr/lib"]

Caused by:
  path segment contains separator `:`
maturin-0.11.2@kusansky$

I don’t think I do anything illegal Unix-wise, but cargo build still hates me.

And yes, technically, I could build Rust packages in specifically non-colon-using directories, but it seems like me working around a broken tool.

@LenaWil
Copy link

LenaWil commented Oct 18, 2022

Just wanted to mention that I also encountered this error on macOS. (which is an UNIX)

And I would like Cargo to warn for it when you call cargo init, which did in fact succeed.

@weihanglo
Copy link
Member

weihanglo commented Oct 24, 2022

Here are some steps to resolve part of this issue from cargo new and cargo init:

  1. In src/cargo/ops/cargo_new.rs, create a new function to check if the path contains invalid character such as :.
  2. Call the function inside both fn init(…) and fn new(…), and emit a warning if containing invalid characters. You can check other rules as references to word the message.
  3. Add new integration tests for both cargo init and cargo new. Their styles of tests are a bit different. cargo init follows how UI tests are constructed, whereas cargo new uses functional tests style.

In addition, these error messages could be collapsed into one message, like:

error: failed to join paths from `${env}` together
    If you set `${env}` manually, check if it contains an unterminated quote character or path separators (usually `:` or `:`). Please avoid using them.
    Otherwise, check if any of path listed below contains those characters:
        "/projects/colon:x/target/debug/deps"
        "/home/user1/.rustup/toolchains/stable-x86_64-linux-unknown/lib"
        "/usr/local/lib"
        "/usr/lib"

@mcepl
Copy link

mcepl commented Oct 24, 2022

1. In `src/cargo/ops/cargo_new.rs`, create a new function to check if the path contains invalid character such as `:`.

What we wanted to emphasize here is that : is in fact NOT an invalid character on Unix™-like platforms.

@weihanglo
Copy link
Member

@mcepl, you're absolutely correct. However, Cargo still cannot join paths that contain : (colon) on Unix-lie platforms. This is implemented here in the standard library, and also mentioned in the manpage of ld.so.

The items in the list are separated by either colons or semicolons, and there is no support for escaping either separator.

What I proposed doesn't devalue your needs. Just a warning to tell people “paths containing such characters might not be built for now” for general cases. I am not sure whether there is a workaround for your situation 😞. Could you share how you solve it these days?

@mcepl
Copy link

mcepl commented Oct 24, 2022

Could you share how you solve it these days?

Poorly. cp -r maturin-0.13.5 /tmp/ covers multitude of sins, but mostly our internal build command uses different (chrooted) filesystem where there are no colons in path.

@RyanAD
Copy link

RyanAD commented Oct 25, 2022

@rustbot claim

@RyanAD
Copy link

RyanAD commented Oct 25, 2022

I should have time to add a better error message over the next couple of weeks.

@bors bors closed this as completed in 64e46b0 Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug Command-init Command-new E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants