HardhatError: HH1: You are not inside a Hardhat project - hardhaterror

Adding Hardhat version 2.12.2 to an existing project either manually to the package.json or by executing one of the commands:
npm i hardhat
npm i --save-dev hardhat
yarn add hardhat
yarn add --dev hardhat
Gave the following error:
HardhatError: HH1: You are not inside a Hardhat project.

The error was resolved by adding a file named hardhat.config.js to the project root directory.
This file can also be added by executing npx hardhat and then selecting Create an empty hardhat.config.js.
I think that the error is misleading and it should be something like this:
"HardhatError: HH1: Could not find the file hardhat.config.js. Are you not inside a Hardhat project?"
Or something like:
"HardhatError: HH1: You may not be inside a Hardhat project. Ensure running npx hardhat at this directory?"
(You can find more on the discussion at: https://github.com/NomicFoundation/hardhat/issues/1400. But it is limited to collaborators now.)

Related

Deploying a smart contract using Hardhat WITHOUT script

Literally everywhere I look (other stackoverflow posts, or official docs), the way to deploy a smart contract is always using a script
npx hardhat run scripts/deploy.js --network ropsten
I am looking for a way to deploy it only using the npm library "hardhat" without actually running a "script" in terminal.
Does anyone know how?
So, what I did was put defaultNetwork: "network name" in the module.exports object inside of your hardhat.config.js file.

Cannot view code coverage on angular-cli new project

I'm trying to figure out how to get code coverage working with #angular/cli but so far i'm not having much luck.
I started a new project using angular CLI. Basically all i did was ng new test-coverage and once everything was installed in my new project folder, I did a ng test --code-coverage. The tests were run successfully but nothing resembling code coverage was displayed in the browser.
Am I missing some dependencies or something else? Any help will be appreciated.
EDIT:
R. Richards and Rachid Oussanaa were right, the file does get generated and I can access it by opening the index.html.
Now i'm wondering, is there a way I could integrate that into a node command so that the file opens right after the tests are run?
here's what you can do:
install opn-cli which is a cli for the popular opn package which is a cross-platform tool used to open files in their default apps.
npm install -D opn-cli -D to install as dev dependency.
in package.json add a script under scripts as follows
"scripts": {
...
"test-coverage": "ng test --code-coverage --single-run && opn ./coverage/index.html"
}
now run npm run test-coverage
this will run the script we defined. here is an explanation of that script:
ng test --code-coverage --single-run will run tests, with coverage, only ONCE, hence --single-run
&& basically executes the second command if the first succeeds
opn ./coverage/index.html will open the file regardless of platform.

Appveyor build failure

I am creating a build with Appveyor on Github use devtool https://github.com/atom/atom-keymap. Although Travis builds success, Appveyor builds still appear error!
I do not know real root cause, but I think I can help with a way to troubleshoot this. Basically you can connect to AppVeyor VM via RDP and debug it. Here are the steps:
Insert - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) before - npm run ci in your appveyor.yml file.
In RDP run the following:
cd c:\projects\atom-keymap
npm run compile
npm run lint
This will bring you to the state to get a repro and debug (because npm run ci is npm run compile && npm run lint && npm run test).
To get a repro npm run test.
To debug the problem, do something like this:
devtool --console node_modules/mocha/bin/_mocha --colors spec/helpers/setup.js spec/* --break
(this will let you debug step-by-step)
or
devtool --console node_modules/mocha/bin/_mocha --colors spec/helpers/setup.js spec/* --watch
(this will let you see a lot of error details)
This is the same what npm run test does, but without switch to quit on error and with debug options.
I went this route myself till this point but my limited knowledge of this npm module did not let me to dig till the root cause.

golang test for sub directories fails

In my use case I am setting up a single go test which runs all _test.go in all packages in the project folder. I tried to achieve this using $go test ./... from the src folder of the project
/project-name
/src
/mypack
/dao
/util
When I try to run the test it is asking to install the packages which are used in the imported packages. For example if I import "github.com/go-sql-driver/mysql", it might have used another package github.com/golang/protobuf/proto. I did not manually import the proto package. The application runs without manually importing the inner package. But when I run the tests it fails. But individual package test succeeded. Do I have to install all the packages in the $go test ./... error manually?
Could anyone help me on this?
You need to run go get -t ./... first to get all test deps.
From the go test -h:
The -t flag instructs get to also download the packages required to
build the tests for the specified packages.

Why doesn't my custom recipes run on AWS OpsWorks?

I've created a GitHub repo for my simple custom recipe:
my-cookbook/
|- recipes/
|- appsetup.rb
I've added the repo to Custom Chef Recipes as https://github.com/my-github-user/my-github-repo.git
I've added my-cookbook::appsetup to the Setup "cycle".
I know it's executed, because it fails to load if I mess up the syntax.
This is my appsetup.rb:
node[:deploy].each do |app_name, deploy|
script "install_composer" do
interpreter "bash"
user "root"
cwd "#{deploy[:deploy_to]}/current"
code "curl -sS https://getcomposer.org/installer | php && php composer.phar install --no-dev"
end
end
When I log into the instance by SSH with the ubuntu user, composer isn't installed.
I've also tried the following to no avail (A nodejs install):
node[:deploy].each do |app_name, deploy|
execute "installing node" do
command "add-apt-repository --yes ppa:chris-lea/node.js && apt-get update && sudo apt-get install python-software-properties python g++ make nodejs"
end
end
Node doesn't get installed, and there are no errors in the log. The only references to the cookbook in the log just says:
[2014-03-31T13:26:04+00:00] INFO: OpsWorks Custom Run List: ["opsworks_initial_setup", "ssh_host_keys", "ssh_users", "mysql::client", "dependencies", "ebs", "opsworks_ganglia::client", "opsworks_stack_state_sync", "mod_php5_apache2", "my-cookbook::appsetup", "deploy::default", "deploy::php", "test_suite", "opsworks_cleanup"]
...
2014-03-31T13:26:04+00:00] INFO: New Run List expands to ["opsworks_initial_setup", "ssh_host_keys", "ssh_users", "mysql::client", "dependencies", "ebs", "opsworks_ganglia::client", "opsworks_stack_state_sync", "mod_php5_apache2", "my-cookbook::appsetup", "deploy::default", "deploy::php", "test_suite", "opsworks_cleanup"]
...
[2014-03-31T13:26:05+00:00] DEBUG: Loading Recipe my-cookbook::appsetup via include_recipe
[2014-03-31T13:26:05+00:00] DEBUG: Found recipe appsetup in cookbook my-cookbook
Am I missing some critical step somewhere? The recipe is clearly recognized and loaded, but doesn't seem to be executed.
(The following are fictitious names: my-github-user, my-github-repo, my-cookbook)
I know you've abandoned the cookbook but I'm almost 100% sure it's because you don't have a metadata.rb file in the root of your cookbook.
Your cookbook name should not contain a dash. I had the same problem, replacing by '_' solved it for me.
If those commands are failing silently, it could be that your use of && is obscuring a failure.
As for add-apt-repository, that is an interactive command. Try using the "--yes" option to answer yes by default, making it no longer interactive.
If you do not execute your command successfully, you will not find the files in the current directory. Check inside the last release folder to see if it had been put there.
It maybe prudent to check if you got the right directory etc setup by changing the CWD to : /tmp