Skip to content

cargo: Add local mode and use it by default #1760

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

Closed
wants to merge 2 commits into from

Conversation

tychosci
Copy link
Contributor

@tychosci tychosci commented Feb 5, 2012

Issue #1756

The changes are the following:

  • Add local mode which does operate with project's ".cargo" rather than "~/.cargo".
  • Use local mode by default. you can change it with "-g" or "--global", for global mode operation.
  • Add functions that required to add lib directory in project's ".cargo" to linker search path.
  • Use std::getopts in cargo.rs to avoid arguments ordering problems.

@graydon
Copy link
Contributor

graydon commented Feb 6, 2012

Hm. Can we rephrase this as 3 modes: local, user and system? "Global" is a bit ambiguous (user/system) and we have a sysroot that the compiler at least knows about, can consider viable for system-level installation.

@graydon
Copy link
Contributor

graydon commented Feb 6, 2012

Otherwise cool, btw :)

@tychosci
Copy link
Contributor Author

tychosci commented Feb 7, 2012

Can we rephrase this as 3 modes: local, user and system?

I think that's better!
I'll add commit to get it to work, it seems to be not so difficult :)

* -g or --mode=user to create/use .cargo under $HOME
* -G or --mode=system to create/use .cargo under sysroot
* by default, `cargo` uses .cargo under current working directory
@tychosci
Copy link
Contributor Author

tychosci commented Feb 7, 2012

changes from previous commit:

  • 2 modes (local/global) to 3 modes (system/user/local)
  • Add note about modes to usage
  • Show the information about where .cargo places when .cargo is successfully initialized
  • Add function that required to grab path of system-level .cargo from cargo.rs

@brson
Copy link
Contributor

brson commented Feb 9, 2012

Hi tychosci. This is looking great, but I have one quibble about how the system cargo files are installed. This appears to put them under $sysroot/.cargo/... which in practice is /usr/local/.cargo. This is a strange place for us to be dropping a custom folder. I would expect the system install to not use the .cargo folder and just put libs under /usr/local/lib, bins under /usr/local/bin so that they are on all the normal search paths (rustc already looks here). I can make this change myself, but I'd like to hear your and @graydon's opinion.

@brson
Copy link
Contributor

brson commented Feb 9, 2012

Oh, if we did that though we would not have a place to put all of cargo's work files.

@brson
Copy link
Contributor

brson commented Feb 9, 2012

OK. I pushed this but disabled system mode so we can reconsider how it works. Added #1795. Thanks!

@brson brson closed this Feb 9, 2012
@tychosci
Copy link
Contributor Author

tychosci commented Feb 9, 2012

Ah, I did not notice about that, since I always install rustc and its libs and tools with --prefix :(

I agree that /usr/local is weird place to put .cargo directory for that reason, and it's really good to put installed bin/libs into /usr/local/bin or /usr/local/lib, because we don't need to add another path to $PATH if it's so.

I personally think /usr/local/lib/cargo is good place to store system-level resources for cargo, and symlinking bin/libs in /usr/local/lib/cargo/bin and /usr/local/lib/cargo/lib to /usr/local/bin/<bin> and /usr/local/lib/<lib> after the installation with cargo install <package> is really great.

Furthermore, I think all operations by user-mode and local-mode should use resources of system-mode's cargo.
I realized it's annoying thing that "whenever we create new project and install libraries with cargo, it's necessary to execute cargo init and cargo sync at first", while I was testing cargo with N-modes.

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.

3 participants