trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

Errror: Something already exists at the destination. Please unbox in an empty folder. Stopping to prevent overwriting data. #831

Closed VanThanh1812 closed 6 years ago

VanThanh1812 commented 6 years ago

Hi I have problem when run truffle init. Error: Something already exists at the destination. Please unbox in an empty folder. Stopping to prevent overwriting data. at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-box/lib/utils/unbox.js:22:1 at process._tickCallback (internal/process/next_tick.js:109:7) at Module.runMain (module.js:607:11) at run (bootstrap_node.js:423:7) at startup (bootstrap_node.js:147:9) at bootstrap_node.js:538:3 Any one help me, pls. Thanks.

cgewecke commented 6 years ago

@VanThanh1812 Could you run ls -A at your console prompt and see if the directory you're unboxing in has any contents? If so the unbox command won't work because it doesn't want to risk overwriting anything. You should be able to create a new directory, navigate to it and then unbox. For example

mkdir VanToken
cd VanToken
truffle init

If this doesn't work please report back.

VanThanh1812 commented 6 years ago

Oh, thank you, that's work, I did follow tut in medium then run npm init first. I think that is the cause of my problem :))

DeepakSuryaS commented 6 years ago

i got the same error. i first ran npm init -y and then i ran truffle init, so i have package.json in my folder. should i create a new folder inside of this folder to run truffle init successfully?

DeepakSuryaS commented 6 years ago

@cgewecke running ls -A shows the package.json file

cgewecke commented 6 years ago

@DeepakSuryaS Hi, unbox only works in an empty folder to prevent any possibility of a box overwriting existing folder contents. The best thing to do is unbox first and npm init second.

DeepakSuryaS commented 6 years ago

@cgewecke ok, thanks!

ImmuneGit commented 6 years ago

:) it doesn't work if there is a hidden .git folder. is it really properly?

Matrixbirds commented 6 years ago

@ImmuneGitPlease unbox in an empty folder. You must run this command in empty folder without any file.

ImmuneGit commented 6 years ago

yes, I see that it works for empty folder. But it’s not always logical. For example, I’ve clone a new empty project from git where I want to init truffle project. In that case it doesn’t work and I have to do it in another empty folder and then copy all files and folders to my project folder.

klassicd commented 6 years ago

If you install truffle local to the application (e.g. yarn add truffle), and try to use it (e.g. ./node_modules/bin/truffle init), this error prevents you.

YuxuanLin commented 6 years ago

Same happened and this solution does help me! Thanks The tut I followed:https://medium.com/@merunasgrincalaitis/the-ultimate-end-to-end-tutorial-to-create-and-deploy-a-fully-descentralized-dapp-in-ethereum-18f0cf6d7e0e

gerchicov-bp commented 6 years ago

I have the same issue on OSX. But NOTE: I deleted all the files from the current folder and now it is empty. I've also enabled showing of hidden files - the folder is really empty. I also tried to recreate this folder - the same result Just WTF?

$ truffle init                                                                                                                                                                                       
Downloading...                                                                                                                                                                                               
Error: Something already exists at the destination. Please unbox in an empty folder. Stopping to prevent overwriting data.                                                                                   
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-box/lib/utils/unbox.js:22:1                                                                                                              
    at <anonymous>                                                                                                                                                                                           
    at process._tickCallback (internal/process/next_tick.js:118:7)                                                                                                                                           
    at Function.Module.runMain (module.js:692:11)                                                                                                                                                            
    at startup (bootstrap_node.js:194:16)                                                                                                                                                                    
    at bootstrap_node.js:666:3  

and of course hasn't truffle "uninstall" option?

gerchicov-bp commented 6 years ago

Found out - OSX created "superhidden" file ".DS_Store" which is not shown in Finder and usual terminal command "ls" without params. I saw it with ls -A only. But it is a system file and why truffle doesn't allow to call init in this folder? It is a bug.

Cryt1c commented 6 years ago

I also just ran into this problem, when I first setup a new project in WebStorm and then wanted to do a truffle init. The .idea folder from WebStorm was getting in the way. Would be awesome if this behavior would be changed.

gerchicov-bp commented 6 years ago

it should promt something like "do you really want to install in this folder? Existing files will be overwritten". But now it just refuses such folders at all

l3x commented 6 years ago

Run this:

mkdir mydapp
cd mydapp
truffle init

Of course, you'll likely want to name your directory something other than mydapp

Next, you can run npm init and the rest of your commands.

The problem is that truffle init must be run in directory that no files in it.

n13 commented 6 years ago

It's an annoying limitation - if it's going to be so picky, it should check if it in fact would override any of the existing files, like .git directory, or existing npm files. I guess this wasn't in older versions because I am following a tutorial and running into this issue, and the guy on youtube clearly didn't have problems.

cgewecke commented 6 years ago

Re-opening since this irritates so many people - but going to give some background as well so there's room for discussion about the best approach. Before we made unbox (which is the parent command of init) so strict, there was an issue like this one where the complaint was: unbox deleted my files!! The underlying problem is the following:

Cryt1c commented 6 years ago

@cgewecke Thanks for these insights. I think you are right, that the people who did not get their files deleted through this are underrepresented.

Could truffle init just check if these files/folders exist and if not just go ahead?

cgewecke commented 6 years ago

@Cryt1c Yes - agree - I think that's a good idea.

lazzarello commented 6 years ago

This same problem exists on my computer with a blank, uninitialized directory

2blockchains:gradient-token-tutorial leeazzarello$ truffle init
Downloading...
Error: Something already exists at the destination. Please unbox in an empty folder. Stopping to prevent overwriting data.
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-box/lib/utils/unbox.js:22:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:236:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
2blockchains:gradient-token-tutorial leeazzarello$ ls -la
total 8
drwxr-xr-x   3 leeazzarello  staff    96 Aug 19 15:37 .
drwxr-xr-x  44 leeazzarello  staff  1408 Aug 19 15:37 ..
-rw-r--r--   1 leeazzarello  staff   175 Aug 19 15:37 package.json

2blockchains:gradient-token-tutorial leeazzarello$ truffle version
Truffle v4.1.7 (core: 4.1.7)
Solidity v0.4.23 (solc-js)

2blockchains:gradient-token-tutorial leeazzarello$ which truffle
/usr/local/bin/truffle
eggplantzzz commented 6 years ago

Truffle 5 now allows you to unbox/init in a non-empty folder. If there are name conflicts, it now prompts you to see if you want to overwrite the conflicting files. There is also a --force option for both init and unbox which forces the unbox/init without the prompt. Closing this issue.

HARIKIRAN7382 commented 6 years ago

In mac os we use unbox or init for unboxing or initialization . But in Windows command prompt which command we have to use for unboxing or initialization?

sebastiantf commented 5 years ago

Truffle 5 now allows you to unbox/init in a non-empty folder. If there are name conflicts, it now prompts you to see if you want to overwrite the conflicting files. There is also a --force option for both init and unbox which forces the unbox/init without the prompt. Closing this issue.

It would be better if this feature was added to v4 too. I ended up in this situation:

  1. I already have v5 installed globally
  2. I wanted to setup a truffle project using v4
  3. So I installed v4 locally in my project folder
  4. Used npx truffle init to use the local version v4
  5. Got the error: Error: Something already exists at the destination. Please unbox in an empty folder
Mryolk commented 2 years ago

Hello Everyone! i am very new to all these and i'm trying to unbox metacoin with Truffle. so this is what is happening: C:\Users\Giannis\Metacoin>truffle unbox Metacoin node:internal/modules/cjs/loader:936 throw err; ^

Error: Cannot find module 'C:\Users\Giannis\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js' ←[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m ←[90m at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m ←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)←[39m ←[90m at node:internal/main/run_main_module:17:47←[39m { code: ←[32m'MODULE_NOT_FOUND'←[39m, requireStack: [] Any help please...?