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

fix: Collect usage statistic showing twice #328

Closed
wolfenrain opened this issue Mar 21, 2022 · 9 comments
Closed

fix: Collect usage statistic showing twice #328

wolfenrain opened this issue Mar 21, 2022 · 9 comments
Assignees
Labels
bug Something isn't working as expected

Comments

@wolfenrain
Copy link
Member

wolfenrain commented Mar 21, 2022

Description
When running the very_good_cli for the first time it asks if it can collect usage statistics. If you say yes then it will output the exact message once more.

Steps To Reproduce

  1. Install the very_good_cli from clean (tested it with v0.6.0)
  2. Run a very_good create command
  3. When asked if it can collect data say yes.
  4. It outputs the same message again and continues.

Expected Behavior
That it will only show the message asking to collect data once, before answering and not again after answering the question.

Screenshots
image

Additional Context
I did run it on dart version 2.15.1 by accident but I was able to reproduce it after updating and clean installing the tool.

  • Terminal: bash v5.1.8
  • OS: pop-os 21.10
@wolfenrain wolfenrain added the bug Something isn't working as expected label Mar 21, 2022
@felangel
Copy link
Contributor

Hi @wolfenrain 👋
Thanks for opening an issue!

Are you able to provide more context regarding what OS you're running on? Also, can you confirm that other commands only execute once? The reason I ask is because there have been similar issues reported like leoafarias/fvm#227 and #121.

@felangel felangel added the waiting for response Waiting for follow up label Mar 21, 2022
@wolfenrain
Copy link
Member Author

wolfenrain commented Mar 21, 2022

Hi @wolfenrain wave Thanks for opening an issue!

Are you able to provide more context regarding what OS you're running on? Also, can you confirm that other commands only execute once? The reason I ask is because there have been similar issues reported like leoafarias/fvm#227 and #121.

The command itself ran only once, it also only happened after I gave an answer.

I am currently running it on Linux, pop-os 21.10

@felangel felangel added investigating and removed waiting for response Waiting for follow up labels Mar 21, 2022
@felangel felangel self-assigned this Mar 21, 2022
@wolfenrain
Copy link
Member Author

So I managed to reproduce this inside a Docker container, while that obviously does not fully reflect any working environment the problem itself is consistent on my Linux machine so I suspect this is a Linux + Bash problem?

Might still be a problem specific to the terminal emulator that is being used, can't test that right now.

  1. Run docker run -ti dart:2.16.1 /bin/bash to start a container with Dart v2.16.1 and with bash as the shell. PS: I did test other versions of Dart as well and they all resulted in the same outcome.
  2. Install the CLI: dart pub global activate very_good_cli
  3. The container does not have proper PATH variables for Dart so just run it from the cache: .pub-cache/bin/very_good
  4. The question pops up, press y and enter.
  5. The question pops up again, so it now shown twice and the answer you gave is below that. Rest works as expected the help is visible.

@wolfenrain
Copy link
Member Author

wolfenrain commented Mar 22, 2022

Might still be a problem specific to the terminal emulator that is being used, can't test that right now.

This is no longer uncertain, I have followed these steps on my intel macbook and got exactly the same results. So either the stdout writing is going haywire (based on a quick assessment of the code for this I would assume that it is not the case) or the CLI and Bash/Linux aren't the greatest friends (yet).

@felangel felangel removed their assignment Mar 28, 2022
@wolfenrain
Copy link
Member Author

Based on this method I wrote up a simple test file to see if the problem is reproducible in a simplere case.

The test I wrote up ran in a Docker VM on Dart 2.16.1, I initially just used the stdout and stdin from dart:io:

import 'dart:io';

void main() {
  const message = 'testing this';
  stdout.write(message);

  stdin.readLineSync()?.trim();

  stdout.writeln('\x1b[A\u001B[2K$message with result');
}

This does not result in the problem describe above. So I took a quick look at the universal_io, expected it to just reexport dart:io but it seems they have their own implementation of stdio, and it seems to be a full copy, based on the license at the top, from the dart stdio one.

So considering that it is working without universal_io as expected I suspect the problem might lie somewhere in their implementation.

@felangel
Copy link
Contributor

Based on this method I wrote up a simple test file to see if the problem is reproducible in a simplere case.

The test I wrote up ran in a Docker VM on Dart 2.16.1, I initially just used the stdout and stdin from dart:io:

import 'dart:io';

void main() {
  const message = 'testing this';
  stdout.write(message);

  stdin.readLineSync()?.trim();

  stdout.writeln('\x1b[A\u001B[2K$message with result');
}

This does not result in the problem describe above. So I took a quick look at the universal_io, expected it to just reexport dart:io but it seems they have their own implementation of stdio, and it seems to be a full copy, based on the license at the top, from the dart stdio one.

So considering that it is working without universal_io as expected I suspect the problem might lie somewhere in their implementation.

Hmm that's interesting! Thanks for looking into it. Are you planning to try swapping out dart:io with universal_io in your example to see if you're able to reproduce?

@wolfenrain
Copy link
Member Author

wolfenrain commented Mar 29, 2022

Hmm that's interesting! Thanks for looking into it. Are you planning to try swapping out dart:io with universal_io in your example to see if you're able to reproduce?

Yes I already tried, but it was throwing some segmentation errors when I tried to run the file in Docker 😅 , but I can give it another go later today.

@wolfenrain
Copy link
Member Author

The bug is in mason_logger, doesn't support multi-line messages properly for the prompt method.

I put a PR for that, so after that is merged and released we can resolve this issue by just upgrading.

@felangel
Copy link
Contributor

This should be resolved now. Developers should be able to just re-activate very_good_cli to get the latest release of package:mason_logger which includes the fix 🎉

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

No branches or pull requests

2 participants