diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php
index 0fa0d7564..f0f41a006 100644
--- a/src/Composer/Command/InitCommand.php
+++ b/src/Composer/Command/InitCommand.php
@@ -349,7 +349,17 @@ EOT
));
}
- $requirement['version'] = $package->getPrettyVersion();
+ $version = $package->getPrettyVersion();
+ if (!$package->isDev()) {
+ // remove the v prefix if there is one
+ if (substr($version, 0, 1) == 'v') {
+ $version = substr($version, 1);
+ }
+
+ // 2.1.0 -> ~2.1.0, 2.0-beta.1 -> ~2.0-beta.1
+ $version = '~'.$version;
+ }
+ $requirement['version'] = $version;
$output->writeln(sprintf(
'Using version %s for %s',