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

Installation with syntax highlighting fails #252

Closed
little-dude opened this issue Jul 2, 2017 · 5 comments
Closed

Installation with syntax highlighting fails #252

little-dude opened this issue Jul 2, 2017 · 5 comments
Labels
bug Not as expected

Comments

@little-dude
Copy link

little-dude commented Jul 2, 2017

Hi,

I'm trying to install cobal with cargo install cobalt-bin --features="syntax-highlight", but the build fails:

   Compiling cobalt-bin v0.7.1               
error: no associated item named `load_defaults_newlines` found for type `syntect::parsing::SyntaxSet` in the current scope     
  --> /home/corentih/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/cobalt-bin-0.7.1/src/syntax_highlight.rs:36:21            
   |                                         
36 |         syntax_set: SyntaxSet::load_defaults_newlines(),                             
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                

error: no associated item named `load_defaults` found for type `syntect::highlighting::ThemeSet` in the current scope          
  --> /home/corentih/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/cobalt-bin-0.7.1/src/syntax_highlight.rs:37:20            
   |                                         
37 |         theme_set: ThemeSet::load_defaults()                                         
   |                    ^^^^^^^^^^^^^^^^^^^^^^^                                           

error: aborting due to 2 previous errors     

error: failed to compile `cobalt-bin v0.7.1`, intermediate artifacts can be found at `/tmp/corentih/cargo-install.URcVDaLAXnXm`

Caused by:                                   
  Could not compile `cobalt-bin`.            
@little-dude little-dude changed the title Installation fails Installation with syntax highlighting fails Jul 2, 2017
@epage epage added the bug Not as expected label Jul 2, 2017
@epage
Copy link
Member

epage commented Jul 2, 2017

Ouch. Thanks for reporting this. I've reproduced this on my machine as well.

Things that need to be looked into

  • Why this is happening
  • Why was this not caught

@boxofrox
Copy link
Contributor

boxofrox commented Jul 2, 2017

cargo install cobalt-bin --features=syntax-highlight is building against syntect v1.7.0.

   Compiling syntect v1.7.0
   Compiling cobalt-bin v0.7.1
error: no associated item named `load_defaults_newlines` found for type `syntect::parsing::SyntaxSet` in the current scope
  --> /home/charetjc/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/cobalt-bin-0.7.1/src/syntax_highlight.rs:36:21
   |
36 |         syntax_set: SyntaxSet::load_defaults_newlines(),
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: no associated item named `load_defaults` found for type `syntect::highlighting::ThemeSet` in the current scope
  --> /home/charetjc/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/cobalt-bin-0.7.1/src/syntax_highlight.rs:37:20
   |
37 |         theme_set: ThemeSet::load_defaults()
   |                    ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: failed to compile `cobalt-bin v0.7.1`, intermediate artifacts can be found at `/tmp/charetjc/cargo-install.zyGXltgtH1r4`

Caused by:
  Could not compile `cobalt-bin`.

To learn more, run the command again with --verbose.

I cloned cobalt-rs and cargo build --features=syntax-highlight succeeds and builds with syntect v1.5.0 as per the Cargo.toml. This is probably why testing did not catch the error.

If I bump the syntect version in the Cargo.toml to v1.7.0, then cargo build --features=syntax-highlight fails with the same error.

Looks like dump-load or dump-load-rs[1][2] must be added to the syntect features to compile the missing functions in v1.7.0.

[1]: https://github.com/trishume/syntect/blob/v1.7.0/src/dumps.rs#L98
[2]: https://github.com/trishume/syntect/blob/v1.7.0/src/dumps.rs#L132

Not sure why cargo install doesn't use syntect v1.5.0. Perhaps a bug with cargo install?

@boxofrox
Copy link
Contributor

boxofrox commented Jul 2, 2017

Not a bug in cargo.

The Cargo.toml specifies:

[dependencies.syntect]
version = "1.5"
optional = true
default-features = false
features =  ["parsing", "assets", "html", "static-onig"]

According to the cargo docs [1]...

^1.2 := >=1.2.0 <2.0.0

...and v1.7 is considered a valid and backward-compatible version in accordance with semver.org.

So, either syntect intentionally broke backwards-compatibility in v1.7.0 with the new features, or there's a bug in their #[cfg(features)] expressions, and they wanted an OR operation instead of AND? I guess compatibility depends on how semver is applied to feature flags.

syntect tries to maintain backward compatibility through its features.default, which cobalt-rs disables.

PR 84 [2] added the new dump-load* feature requirement.

[1]: http://doc.crates.io/specifying-dependencies.html#caret-requirements
[2]: trishume/syntect#84

@epage
Copy link
Member

epage commented Jul 4, 2017

I find the recommendation for bins to checkin their Cargo.lock file interesting when cargo install doesn't use it. I wonder if there is something to that.

@boxofrox
Copy link
Contributor

boxofrox commented Jul 4, 2017

I hadn't considered that angle. Checking in Cargo.lock certainly helps consistency among developers when building the source. Seems like cargo install may be an oversight.

From a unix perspective, it makes sense for software to take advantage of the latest compatible library versions, and cargo's reliance on semver compliance would facilitate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not as expected
Projects
None yet
Development

No branches or pull requests

3 participants