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

diesel_cli v1.3 print-schema broken on WIN10 #1723

Closed
Deedasmi opened this Issue May 23, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@Deedasmi
Contributor

Deedasmi commented May 23, 2018

Setup

With diesel_cli 1.2:

diesel print-schema gives correct output.

With diesel_cli 1.3:
diesel print-schema gives

Access is denied. (os error 5)

Versions

  • Rust: nightly-2018-05-14/1.26 Stable
  • Diesel: 1.3
  • Database: PG10
  • Operating System WIN10

Feature Flags

  • diesel: Postgres

Checklist

  • [ X ] I have already looked over the issue tracker for similar issues.
  • [ X ] This issue can be reproduced on Rust's stable channel.

Doing some troubleshooting, but it's 1 am and I might pass out. Will figure out cause tomorrow at latest.

@weiznich

This comment has been minimized.

Contributor

weiznich commented May 23, 2018

This sounds like you don't have the needed rights to read from the postgres information schema with your current user.

@Deedasmi

This comment has been minimized.

Contributor

Deedasmi commented May 23, 2018

Why would it work on the previous version then? I downgraded to 1.2 and it worked fine.

I've tracked the error down to https://github.com/diesel-rs/diesel/blob/master/diesel_cli/src/print_schema.rs#L57, but haven't figured out why its failing yet.

@Deedasmi

This comment has been minimized.

Contributor

Deedasmi commented May 23, 2018

extern crate tempfile;
use tempfile::NamedTempFile;
use std::fs::File;
use std::io;

fn main() -> Result<(), io::Error> {
    let tempfile = NamedTempFile::new()?;
    let mut out = File::create(tempfile)?;
    Ok(())
}

Fails on my system. Seems like this is an issue with tempfile.

@weiznich

This comment has been minimized.

Contributor

weiznich commented May 23, 2018

Is your temp directory writable for your current user? If not this seems more like a system configuration issue.

@Deedasmi

This comment has been minimized.

Contributor

Deedasmi commented May 23, 2018

Opened Stebalien/tempfile#56.

Made a better test where I can write a PathBuf file, but not a NamedTempFile. This one looks... fun lol.

@Deedasmi

This comment has been minimized.

Contributor

Deedasmi commented May 23, 2018

I actually think diesel is using tempfile incorrectly. https://docs.rs/tempfile/3.0.2/src/tempfile/file/mod.rs.html#371-374

NamedTempFile already creates a File. By passing the path to File::create() we're trying to create a new file on top of an open file handle.

@KodrAus

This comment has been minimized.

KodrAus commented May 23, 2018

@Deedasmi that's right, NamedTempFile::new will create the temporary file it wraps before it returns.

weiznich added a commit to weiznich/diesel that referenced this issue May 23, 2018

Correctly use `NamedTempFile`
Do not try to open the generated temp file twice. This will fail on
windows.

Fixes diesel-rs#1723

@sgrif sgrif closed this in #1724 May 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment