These are chat archives for rust-lang/rust

20th
Mar 2018
Zakarum
@omni-viral
Mar 20 2018 10:27
Is there a special way to convert a pair of RangeFrom<T> and RangeTo<T> into Range<T>?
Daniel Bischof
@dbischof90
Mar 20 2018 10:37
let rf = std::ops::RangeFrom{ start: 1 }
let rt = std::ops::RangeTo{ end: 1 }

let range = std::ops::Range { start: rf.start, end: rt.end }
Trivial but I don't think there's a 'nicer looking function' from looking at the documentation of RangeFrom etc. Even if, I think it wouldn't do much more than that. The start and end fields are public, so you can access them.
Zakarum
@omni-viral
Mar 20 2018 11:04
@dbischof90 Well. I do rf.start .. rt.end right now.
I just don't want to screw up semantics and do rt.end .. rf.start by any chance :smile:
Ingvar Stepanyan
@RReverser
Mar 20 2018 18:36
@omni-viral that seems an unlikely mistake, but you can always use pattern matching if you really want to :)
let RangeFrom { start } = from_range;
let RangeTo { end } = to_range;
let range = Range { start, end };
Azriel Hoh
@azriel91
Mar 20 2018 19:10

Hiya! Hopefully I can ask for support here.
I hit an issue on Ubuntu where std::env::current_dir() is returning a Permission denied error, but I haven't been able to trace the cause. I'm hoping the hive mind can help figure this out.
Full investigation details are on sagiegurari/cargo-make#81 , the summary points:

  • I'm using cargo-make to run a script.
  • cargo-make eventually calls std::env::current_dir(), and that returns a EACCES error (permission denied).
  • The directory exists, I can reproduce the error by running cargo-make as the gitlab-runner user inside the directory itself.
  • The directory and all its parent dirs are owned by that user.
  • The first time this error happened was on my gitlab-runner user during a build, but it has happened once to my normal user yesterday.
  • This is a transient error, but consistently happens once it has happened (it goes away when I restart my computer, for example, but somehow comes back later).
  • Writing a trivial program that calls std::env::current_dir() and printing it, during the time the error can be reproduced, works.

This happens on nightly-2018-03-16-x86_64-unknown-linux-gnu, as well at the latest nightly (nightly-2018-03-19)

Ingvar Stepanyan
@RReverser
Mar 20 2018 19:22
@azriel91 This doesn't sound like a question for community, more like issue report
I'd suggest to report it on Rust repo where you could get some help.
Azriel Hoh
@azriel91
Mar 20 2018 19:25
okay, I haven't been able to confirm where the error lies (whether Rust, cargo-make, gitlab-runner, Ubuntu, or my laptop), so it's hard to choose a place to post ._.. I'll try the users forum to see if anyone has ideas
Zomerfaun
@zomerfaun
Mar 20 2018 20:13
@azriel91 That sounds like a very, erm, interesting error :sweat_smile: Have you tried running it under strace to see whether that gives any additional information/clues?
Azriel Hoh
@azriel91
Mar 20 2018 20:17
@zomerfaun oh my, you deserve a high-five (and much more than that). There's a useful log message:
openat(AT_FDCWD, "/tmp/run_script/3DfZ5Dn5zD.sh", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = -1 EACCES (Permission denied)
:bow:
my (lack of) sysadmin skills are showing :sweat_smile:
Zomerfaun
@zomerfaun
Mar 20 2018 20:20
@azriel91 I am glad it helped :D my own debugging skills are very limited, I basically strace all the things when I don't know what's going on
Ingvar Stepanyan
@RReverser
Mar 20 2018 20:44
Heh, glad to see I was wrong :D
Azriel Hoh
@azriel91
Mar 20 2018 21:25
20180321 zomerfaun sketch.jpg
@zomerfaun sweet, the fix is being worked on now :+1:
while i waited, i sketched this ambigram
Zomerfaun
@zomerfaun
Mar 20 2018 22:27
@azriel91 holy wow that is too awesome!! :D :bow: you are amazing. that means more to me than I can tell you :heart: