Can't pass test build_solutions_octave

Hello how are you?

Does anyone know what this error means?
image
I have not been able to decipher what the problem is, my solution has no problems when compiling. Any comment would be very helpful.

Hi, If you can send the complete result we can understand more about that, but I have some questions that can help, that is a local build?, are you using windows with wsl or any distro?

When i was making local build sometimes fail, because I present some problems with my nix installation, for that reason sometimes I must try with the CI and read from that, if it’s a locally run probably it’s a fail in parallels or nix (happens to me a lot of times).

But it’s a supposition, I can’t know anymore about that with only that image (that seems that nix can’t build the derivation and parallel fails or you have a real issue in the code, but i can’t see it with that fragment)

This is an example image with the complete error.

Hi, thank you so much for answering. No, it isn´t local build :frowning: . Here’s the complete result.

Hellooo … I’m having this error when trying to commit :pensive: … do you know what it is ?

Your error:

fscanf: invalid stream number = -1

Probably this may help.

The error is in your code, try to read the link that I put for you or found another workaround :smile:

The good thing is that now you know why fail.

@Black-Moon

Are you sure that is the same error?

Please read the reply that I do if is the same, but if not, open a new thread with your error, I will help you if I can :smile:

@suspicious-flame

You can found a solution for that error?

When you can found a solution for that error, please check this thread as a solved.

Hi @suspicious-flame,

did you test your code with the lint for octave?
I am not sure about octave, but for example for python you can use pylint or mypy and for ruby you can use rubocop.

In a “normal” compiling your code will compile sure!, but when you test your code with the linter or try to linting your code it would show you detailed changes for your code that you should pass by 100%.

Maybe if you do this first, before doing the build_solutions_octave it would be less annoying.

I found this octave-lint
good luck!

How I see the error can be solved handle the case when fopen = -1,

Because that happens when fopen can’t read the file, the best way is make a handle for that or make a code that can receive an input.

I will say the same that I say in another thread about octave.

2 ways:

  • read inputs, no files, with that way you can use cat DATA.lst | <run your file here> this is the accepted way in the repo, because open the file was deprecated (1 month ago you can open the file).

  • handle the error when fopen = -1 with something like: if fopen == -1, exit or close or print error.

An important part of this process is that you try to learn how to handle errors, not only pass the checks, for example, what happen if you have a function that get some params like a string, but when the function is calling the string for some reason Is null?

That example is exactly what happens with the file, you can fix that handle the error when the function receive unexpected things (or receive nothing).

This is related to your error, but is better that you try to use inputs because in the repo they want that you can send the Data like an argument.

(You can mix the inputs with a file with a function that work with inputs if receive any argument, if not, that work with a file, you can see an example of that searching some solutions with this name: richardalmanza.cr).

Hello, thank you very much for the help, I did it in the way of point two and I verified it locally and it passed the test.
It is rare that this error appeared because when I wrote the code (solution) fopen is always greater than zero. Anyway, if the pipeline fails again I have option 1 to read inputs.
Thank you!!!

I think that fopen can become -1 when you run the CI because when nix build the derivations to test your code can happen 2 things:

  1. Nix didn’t build DATA.lst in the derivations, for that reason the file didn’t exist when nix try to test the code.

  2. Nix build the file DATA.lst but with another file name because the derivation.

But if you handle the error I think that you code can pass the CI, but it’s possible that can be rejected in the revision if the code didn’t admit the for cat DATA.lst | <run code>

But is good that you figure out how to solve that problem. :smile:

1 Like

Hello again. I have a question with this command cat DATA.lst | <run your file here>, according to what I have consulted. “cat is useful for producing output in user-defined functions. It converts its arguments to character vectors, concatenates them to a single character vector, appends the given sep = string (s) to each element and then outputs them”. So they ask me to use this command to “open” the DATA.lst file, but it doesn’t work for that, I don’t understand how it MUST be done.
Cat creates an iteration with the user, so that it is he who delivers the data, but it should not be.
I have my code like this input <- cat("DATA.lst") but my MR is not accepted because it is not hardcoded file. I just don’t get it.

Ok, I found your problem, but this is for make another thread, but I will help you here.

image

If you see the blue arrow you can see that you are hardcoded the file into your code, the command cat must be executed as an argument in your command line (you should put it in the postlude too in the red arrow place).

You must make that you can receive arguments and work with that arguments, you must execute your code in the command line with something like this:

$ cat DATA.lst | Rscript valearizag.r

With that you must try to catch that arguments and use it in your code.

You don’t need to call the file, because the file can be anything, the file can exist or not or can have another name, for that reason you shouldn’t hardcoded the file, you should try to load the arguments with that file. In the majority of cases the stdin can read the arguments.

How you can work with the arguments depends for you and the language, for example when i was making challenges in crystal I was able to get all data like a string, and split then by “\n”, with that I can get each line.

In can work with that but in a different way, each character can be readed like an input, or I can read the entire line, you should figure out how you feel better to work with the argument that you receive.

Hey thank you!
So, according to what I understood, it would be something like this:
input <- scan()
write.table(input, file = “DATA.lst”, row.names = FALSE)
The user enters the arguments that the code reads and saves in the DATA.lst file?
Would the rest of the code work with those arguments read by the code?

The truth is that I don’t know much how to work with octave, but You don’t need to mention the name of the file inside of the code, in the code you should use stdin to receive the inputs or arguments and you don’t need to use the file, you can do it interactive, but when you run it with the command line try to send the DATA like an argument.

A little example with python:

a = input()
print(a)

# $ cat DATA.lst | python3 example.py
# Hello World!

Suppose that DATA.lst in this case has Hello World! in the first line.

you didn’t need to hardcoded the DATA.