question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Build" calls rustc rather than cargo

See original GitHub issue

Sublime Text Version

Sublime Text 3 (Build 3126)

Rust Enhanced Version

1.1.1

Operating system

OS Name macOS Version 10.12.3

Description

Pressing Cmd+Shift+P and selecting “Build With: RustEnhanced” calls rustc, rather than cargo.

I’m getting the following output in the bottom pane:

error[E0463]: can't find crate for `rustc_serialize`
 --> /net/sujin/home/ubuntu/src/rust-playground/src/ohai.rs:1:1
  |
1 | extern crate rustc_serialize;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

[Finished in 0.4s with exit code 101]
[shell_cmd: rustc /net/sujin/home/ubuntu/src/rust-playground/src/ohai.rs]
[dir: /net/sujin/home/ubuntu/src/rust-playground/src]
[path: /Users/primary/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/primary/bin]

Note that the shell_cmd says rustc. As a result of using rustc, it fails to find the external crates we are using.

I believe it should call cargo instead. The cargo binary is in the search path at /Users/primary/.cargo/bin/cargo, so I’m not sure why it’s not working.

If I select Tools -> Build System -> RustEnhanced, and then Tools -> Build, the same thing happens.

If I select Tools -> Build System -> Rust, and then Tools -> Build, the same thing happens.

If I select Tools -> Build System -> Automatic, and then Tools -> Build, it does call cargo, but it doesn’t show build errors in the source code, so I’m having to hunt for line numbers. (I’m not sure if that’s calling the built-in Rust or the RustEnhanced plugin.)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jolisscommented, Feb 14, 2017

Yes, I have two Cargo entries in Tools -> Build System. They both seem to work fine.

Now when I select “Automatic” as the Build System it works as well. I’m not sure if it worked originally or if something changed in the meantime.

In any case, I think there might be a few usability issues at the root of this:

  • Because the package is called RustEnhanced, when I hit Cmd+Shift+P, I expected things to work when I select “Build With: RustEnhanced”. I didn’t even think to look for Cargo.
  • Same for the Build System – I looked for Rust, not for Cargo.
  • It’s hard to know if you’re using the built-in Rust support or the RustEnhanced plugin for many of the commands.

I wonder if “rustc without Cargo” is really at all a popular mode of compiling Rust code. It seems to me that almost everyone would be using Cargo these days. So perhaps we should be steering people towards the Cargo build option as a default.

0reactions
jolisscommented, Feb 27, 2017

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rustc vs Cargo which is better to build - Rust Users Forum
I'd highly recommend cargo. It is the higher level tool for managing your rust projects. rustc and it's flags are available if you're...
Read more >
Cargo vs rustc : r/rust - Reddit
Cargo literally just calls rustc for you with all the compiler flags and whatnot to make it easier on the user to manage...
Read more >
Build Scripts - The Cargo Book
The Rust file designated by the build command (relative to the package root) will be compiled and invoked before anything else is compiled...
Read more >
Is there way to use xbuild instead of build when calling cargo ...
I try to use binutils commands for binary of custom build target with cargo xbuild command. However, I get an error like below...
Read more >
Bypass rustup wrapper when invoking rustc #10986 - GitHub
Invokes rustup wrapper only once; Works when invoking cargo directly rather than via a rustup wrapper. I guess doing 4a now doesn't preclude ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found