Giter VIP home page Giter VIP logo

Comments (6)

argentini avatar argentini commented on July 24, 2024 1

Hey @Tyrrrz thanks for digging into this. I did place an issue with Microsoft about this, so we'll see what they say.

from cliwrap.

Tyrrrz avatar Tyrrrz commented on July 24, 2024

Does that program consume stdin for anything? I think this happens because CliWrap always redirects all standard streams, and some programs may infer that if stdin is redirected, then the user intends to write something to it.

I'm not familiar with SqlPackage but maybe there's an argument you can pass to explicitly disable that behavior. Otherwise, you can try passing PipeSource.FromStream(Stream.Null) for the standard input pipe, but it will probably just result in a different error.

Also see #190, which might be a similar issue.

from cliwrap.

argentini avatar argentini commented on July 24, 2024

Hey @Tyrrrz thanks for the quick response! I did try handling the standard input in that way but I got the same result. I don't believe that SqlPackage bothers with standard input anyway; none of the docs indicate that you can pipe to it.

Attached here is a simple project that shows the failure. Just use the dotnet command below to install SqlPackage, and then run this project. You can easily uninstall SqlPackage with the same command and the word "uninstall" instead of "install".

dotnet tool install -g microsoft.sqlpackage

ConsoleApp1.zip

from cliwrap.

Tyrrrz avatar Tyrrrz commented on July 24, 2024

I was able to reproduce the error with the following minimal code:

using var process = new Process
{
    StartInfo = new ProcessStartInfo
    {
        FileName = "sqlpackage",
        RedirectStandardOutput = true,
        RedirectStandardError = true
    }
};

process.OutputDataReceived += (sender, args) =>
{
    if (args.Data is not null)
    {
        Console.WriteLine(args.Data);
    }
};

process.ErrorDataReceived += (sender, args) =>
{
    if (args.Data is not null)
    {
        Console.WriteLine(args.Data);
    }
};

process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();

process.WaitForExit();

Note that the error appears to only happen when both the output and error streams are redirected, but not when only one of them is.

All in all, this looks like either a bug within the Process class or inside the implementation of SqlPackage (which is more likely). I would recommend raising an issue with them, using the code snippet above. Since this issue is not specific to CliWrap (seeing as it's reproducible with raw Process), I'm going to close it.

from cliwrap.

argentini avatar argentini commented on July 24, 2024

Hey @Tyrrrz I just got this update from Microsoft:

"This is fixed and will be in the August release. Let me know if you want to try it out earlier and we can release a preview version of Microsoft.SqlPackage."

Just thought you would want to know.

from cliwrap.

Tyrrrz avatar Tyrrrz commented on July 24, 2024

Great! @argentini

from cliwrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.